PHP Sorting An Multidimensional Array -


i new php , unsure why code not outputting. have in place no errors , seems correct. trying output names , dates in ascending order while using print_r() verify order. appreciate guidance matter have no idea going wrong.

$win = array('name'=>                          array('jane doe ', 'nash patel ', 'joe public '),               'date'=>                         array('7 october 2015 ', '14 october 2014 ', '12 october 2016 '));  foreach($win $element => $namedate) {     echo '<strong>' . $element . '</strong><br>';     foreach($namedate $both) {        echo $both . '<br/>';     } }  foreach($win $c=>$key) {         $sort_date[] = $key['date'];         $sort_name[] = $key['name'];     }      array_multisort($sort_name, sort_asc, $sort_date, sort_asc, $win);     print_r($win); 

output\

array ( [date] => array ( [0] => 7 october 2015 [1] => 14 october 2014 [2] => 12 october 2016 ) [name] => array ( [0] => jane doe [1] => nash patel [2] => joe public ) )

i've read docs , seems that

array_multisort($sort_name, sort_asc, $sort_date, sort_asc, $win);

means $win sorted name , date, sorting name has bigger priority on date.

try adding more jane doe different dates see they're sorted date.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -