dappa600 Posted November 24, 2008 Share Posted November 24, 2008 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 https://forums.phpfreaks.com/topic/134124-how-to-sort-a-multidimensinal-array-by-one-of-it-colum-other-than-basix-index/ Share on other sites More sharing options...
n3ightjay Posted November 24, 2008 Share Posted November 24, 2008 php.net/array_multisort if you show me the var_dump of your array i can help more Link to comment https://forums.phpfreaks.com/topic/134124-how-to-sort-a-multidimensinal-array-by-one-of-it-colum-other-than-basix-index/#findComment-698197 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.