php - Sorting a 3 dimensional array -


i've got array this

array (     [0] => array         (             [0] => array                 (                     [szam] => 8                     [index] => 0                 )          )      [1] => array         (             [0] => array                 (                     [szam] => 1                     [index] => 0                 )              [1] => array                 (                     [szam] => 7                     [index] => 1                 )          ) 

i thought last cmp work fine

function maxszerintcsokkeno($item1,$item2) {     if ($item1['szam'] == $item2['szam']) return 0;     return ($item1['szam'] < $item2['szam']) ? 1 : -1; } 

with foreach

foreach ($tomb $kulcs => $adat)  usort($adat,"maxszerintcsokkeno"); 

but dosen't anything, advise?

you're sorting temporary variable, meaning changes not applied. following should work you:

for($i = 0, $length = count($tomb); $i < $length; $i++) {     usort($tomb[$i], "maxszerintcsokkeno"); } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -