Wednesday, 15 July 2015

html - php sort array keys in multidimensional array -



html - php sort array keys in multidimensional array -

this question has reply here:

how can sort arrays , info in php? 6 answers

below array

$myarray = array( [1] => array (['mytime']=>1), [7] => array(['mytime']=>2), [2] => array(['mytime']=>3), [3] => array(['mytime']=>4) );

i want sort output of array based on keys...

$myarray = array( [1] => array (['mytime']=>1), [2] => array(['mytime']=>3), [3] => array(['mytime']=>4), [7] => array(['mytime']=>2) );

i have tried ksort($myarray) displays 1 anyways prepare this??

ksort() this:

ksort($myarray);

note: sorting functions not homecoming new sorted array; sort array passed, , homecoming true or false. thus, ksort($myarray) homecoming 1 when successful, , $myarray sorted.

it's clear if read docs: http://php.net/manual/en/function.ksort.php

php html arrays sorting

No comments:

Post a Comment