Mantis - Quercus
Viewing Issue Advanced Details
2014 major sometimes 09-15-07 17:26 09-18-07 10:39
hendler  
nam  
normal  
closed 3.1.2  
fixed  
none    
none 3.1.3  
0002014: array_multisort with main key being non-numeric exhibts odd behavior
doesn't work in quercus, but works in PHP 5.2

 $array_name = array();
 $array['n']['x'] = 123;
 $array['n']['z'] = 123123;
 $array['b']['x'] = 123;
 $array['b']['z'] = 234;
 $array['g']['x'] = 123;
 $array['g']['z'] = 1;
 
 $count_name = 'count';
 ${$count_name} = array();
 foreach ($array as $key => $row) {
    ${$count_name}[$key] = $row['z'];
}
                
                //
eval( ' array_multisort($count,SORT_ASC,SORT_NUMERIC,$array); print_r($array);');


WORKS:

 $array = array();
 $array[0]['x'] = 123;
 $array[0]['z'] = 123123;
 $array[1]['x'] = 123;
 $array[1]['z'] = 234;
 $array[2]['x'] = 123;
 $array[2]['z'] = 1;
 
 
 foreach ($array as $key => $row) {
    $count[$key] = $row['z'];
}
                
                //
eval( ' array_multisort($count,SORT_ASC,SORT_NUMERIC,$array); print_r($array);');

as does
 $array_name = array();
 $array[0]['x'] = 123;
 $array[0]['z'] = 123123;
 $array[1]['x'] = 123;
 $array[1]['z'] = 234;
 $array[2]['x'] = 123;
 $array[2]['z'] = 1;
 
 $count_name = 'count';
 ${$count_name} = array();
 foreach ($array as $key => $row) {
    ${$count_name}[$key] = $row['z'];
}
                
                //
eval( ' array_multisort($count,SORT_ASC,SORT_NUMERIC,$array); print_r($array);');

Notes
(0002295)
hendler   
09-15-07 17:31   
quick note:

the result array remains the same
and the counting array is doubled in length with replicated values but lost keys.
(0002300)
nam   
09-18-07 10:39   
php/175t