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);

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.