Jump to content

How to sort a multidimensinal-array by one of it colum, other than basix index?


dappa600

Recommended Posts

How to sort a multidimensinal-array by one of its colum, other than basix index number?

 

I have text files in /files/ folder, which are named 1,2,3,4, etc and I try to manage links to that data with php array.

<?

$counter = 0;

 

$list = glob("files/*");

 

//count files

foreach ($list as $filename) {

$counter++;

}

 

//now making array containing some key-data from files

 

for ($i = 1; $i <= $counter; $i++){

 

 

$file = 'files/';

$file.= $i;

 

$text = file($file);

$question = $text[0];

$volume = $teksti[21];

$link = "<A href=\"test.php?file=$i\"> $question <A> Volume: $volume <br> ";

 

//get data from files to array

array_push($array, $question, $volume, $link);

 

}

 

//I want that array sorted by volume, which are integer data-field

//I have only managed to print and array which is ordered by its index-number,

 

//sort($array);

 

 

 

//finally print the ordered array, var_dump just for testing

  var_dump($array);

 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.