[4.3.4] Can't ksort a subarray

From: Date: Thu, 25 Mar 2004 16:32:36 +0000
Subject: [4.3.4] Can't ksort a subarray
Groups: php.general 
Request: Send a blank email to php-general+get-181494@lists.php.net to get a copy of this message
I have this little code. I want all arrays sorted case insensitive key order, but only the first dimension gets key sorted properly Thanks -- Richard A. DeVenezia <? $A = array ( "C" => array ( "x" => 1, "Z" => 2, "y" => 3) , "b" => array ( "z" => 1, "Y" => 2, "x" => 3) , "A" => array ( "z" => 1, "X" => 2) ); print_r ($A); // sort dim1 uksort ($A, "strcasecmp"); print_r ($A); // sort each dim2 while (list($key,$dim2) = each ($A)) { uksort ($dim2, "strcasecmp"); } print_r ($A); ?> It comes out Array ( [A] => Array ( [z] => 1 [X] => 2 ) [b] => Array ( [z] => 1 [Y] => 2 [x] => 3 ) [C] => Array ( [x] => 1 [Z] => 2 [y] => 3 ) ) I want Array ( [A] => Array ( [X] => 2 [z] => 1 ) [b] => Array ( [x] => 3 [Y] => 2 [z] => 1 ) [C] => Array ( [x] => 1 [y] => 3 [Z] => 2 ) )

« previous php.general (#181494) next »