Re: Re: sorting arrays
| From: | Brian A. Anderson | Date: | Tue, 08 Mar 2005 23:43:08 +0000 |
| Subject: | Re: Re: sorting arrays | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-210267@lists.php.net to get a copy of this message | ||
> RTFM
> arsort()
Ok, so I use asort(), and I don't get the result I wanted. Instead I get the
script telling me my foreach loop is wrong on the second test round, as if
it did something other than simply sort the array. It seems that I can't
access the array now?
$nar = array('lma-bg51' => 1, 'mcr-vh14' => 2, 'gmc-rr21' =>
5, 'amh-fg23'
=> 1);
foreach( $nar AS $key => $val ) {
echo "$key: $val<br />";
}
$nar = asort($nar);
foreach( $nar2 AS $key => $val ) {
echo "$key: $val<br />";
}