noobh Posted November 14, 2007 Share Posted November 14, 2007 ok this is the code <?php $array = array('one'=>'orange','two'=>'banana','three'=>'grapes','four'=>'lemon','five'=>'apple'); sort($array); foreach($array as $key => $val){ echo $key . "=>" . $val . "<br />"; } This is the output the value are already sorted 0=>apple 1=>banana 2=>grapes 3=>lemon 4=>orange But this is the output that i like five=>apple two=>banana three=>grapes four=>lemon one=>orange the value are sorted and the key are still remain!! i mean the key of apple is still five and not become 0 any idea thanks in advance Quote Link to comment Share on other sites More sharing options...
trq Posted November 14, 2007 Share Posted November 14, 2007 <?php $array = array('one'=>'orange','two'=>'banana','three'=>'grapes','four'=>'lemon','five'=>'apple'); asort($array); foreach($array as $key => $val){ echo $key . "=>" . $val; } ?> Quote Link to comment Share on other sites More sharing options...
noobh Posted November 14, 2007 Author Share Posted November 14, 2007 Thanks a lot bro i spend an hours for searching for this king of function anyway thanks again Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.