Hi All,
I am really struggling with sorting the multi-dimensional array sort, so would be grateful if u can help.
From the php.net it gives the following example:
$data_array["FirstName"][0] = "John";
$data_array["FirstName"][1] = "Marta";
$data_array["FirstName"][2] = "Trent";
$data_array["LastName"][0] = "Lin";
$data_array["LastName"][1] = "Tremblay";
$data_array["LastName"][2] = "Nguyen";
$data_array["Extension"][0] = 5555;
$data_array["Extension"][1] = 2222;
$data_array["Extension"][2] = 3333;
and wanted to sort by the column, "Extension", in ascending order to output the following:
FirstName LastName Extension
Marta Tremblay 2222
Trent Nguyen 3333
John Lin 5555
use:
array_multisort($data_array["Extension"], SORT_NUMERIC, SORT_ASC, $data_array["FirstName"],$data_array["LastName"]);
How can I display the array?
FirstName LastName Extension
Marta Tremblay 2222
Trent Nguyen 3333
John Lin 5555
How I setup my arrays normally is:-
array[1]["string"]
array[2]["string"]
array[3]["string"]
But given the example of the above array_multisort(), I have to change my array setup. Can anyone give me an example.
Thanks..
cj