karthikanov24 Posted November 17, 2009 Share Posted November 17, 2009 hiThe following code, <?php$a=array(0=>array('cat_id'=>17,'cat_parentid'=>10,'cat_name'=>'mercedes'),1=>array('cat_id'=>12,'cat_parentid'=>14,'cat_name'=>'volvo'),2=>array('cat_id'=>16,'cat_parentid'=>11,'cat_name'=>'zen'));print_r($a);echo "<hr>";array_multisort($a);print_r($a);?> gives the out put as follow:Array ( [0] => Array ( [cat_id] => 17 [cat_parentid] => 10 [cat_name] => mercedes ) [1] => Array ( [cat_id] => 12 [cat_parentid] => 14 [cat_name] => volvo ) [2] => Array ( [cat_id] => 16 [cat_parentid] => 11 [cat_name] => zen ) ) --------------------------------------------------------------------------------Array ( [0] => Array ( [cat_id] => 12 [cat_parentid] => 14 [cat_name] => volvo ) [1] => Array ( [cat_id] => 16 [cat_parentid] => 11 [cat_name] => zen ) [2] => Array ( [cat_id] => 17 [cat_parentid] => 10 [cat_name] => mercedes ) )I cant understand that on what basis the array is arranged after multisort() here..on alphabhatic order of key or ascending order of values..or what ??thankskarthikanov24 Link to comment Share on other sites More sharing options...
justsomeguy Posted November 17, 2009 Share Posted November 17, 2009 It may be sorting in numeric order of the first element in each array. The cat_id elements are in ascending order. There are several options you can use with array_multisort if you're looking for a specific sort. Link to comment Share on other sites More sharing options...
karthikanov24 Posted November 17, 2009 Author Share Posted November 17, 2009 hiSo in general,how does array_mutisort() work with out giving extra parameters to it..?will it order according to keys or values or alphabhatics or what?could you explain me please,(i have seen many tutorials..but cant understand...)thankskarthikanov24 Link to comment Share on other sites More sharing options...
justsomeguy Posted November 17, 2009 Share Posted November 17, 2009 I'm not sure, the manual doesn't say what the default sort options are. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.