[thelist] Multidimensional Array sort

Alexis Antonakis admin at antonakis.co.uk
Thu Mar 11 09:57:18 CST 2004


Thanks for that Stéphane.

In fact I DO have the quotes in the code...the output I used (print_r) 
removed them and I didn't notice!

In fact I have just found this function on the php.net site, which does 
the job just fine:

function natsort2d(&$aryInput) {
   $aryTemp = $aryOut = array();
   foreach ($aryInput as $key=>$value) {
    reset($value);
    $aryTemp[$key]=current($value);
   }
   natsort($aryTemp);
   foreach ($aryTemp as $key=>$value) {
    $aryOut[] = $aryInput[$key];
   }
   $aryInput = $aryOut;
}


Regards
Alexis

DESCHAMPS Stéphane DSI/SICOR wrote:

>>I am trying to sort multidimensional arrays in PHP. I have 
>>been trying 
>>to use the function 'array_multisort'. 
>>:-array_multisort($ar[1], $ar[0], 
>>ar[2], $ar[3])
> 
> [...]
> 
>>but if I change the 'inner' array from numbers to "words", 
>>then it does not:
> 
> 
> Hi Alexis,
> 
> Try just this :
> 
>              ["Callsign"] => EE1
>              ["Sort"] => EE1
>              ["ID"] => 7
>              ["Type"] => C650
> 
> Quotes are required in PHP :)
> 
> 
> 




More information about the thelist mailing list