RE: [PHP] Re: Determine variable with the lowest value?
| From: | Paul Fine | Date: | Mon, 18 Oct 2004 14:29:44 +0000 |
| Subject: | RE: [PHP] Re: Determine variable with the lowest value? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199724@lists.php.net to get a copy of this message | ||
Than you very much Matt.
Does what I needed. Now I will have to read up on "as" and the function
"key".
-----Original Message-----
From: Matt M. [mailto:h.dudeness@gmail.com]
Sent: October 14, 2004 11:27 AM
To: BOOT
Cc: php-general@lists.php.net
Subject: Re: [PHP] Re: Determine variable with the lowest value?
On Thu, 14 Oct 2004 10:52:20 -0500, BOOT <pfine@of-law.com> wrote:
> OK thanks but I guess I didn't explain what I am trying to do properly.
>
> I need to be able to identify the variable name as well as pick the
variable
> with the lowest value.
>
> Something like this:
>
> Whose turn is it to take out the garbage?
>
> Mike has done it 3 times
> Bob has done it 2 times
> Jane has done it 5 times
> etc...
>
> Therefore its Bob's turn.....
$arr['Mike'] = 3;
$arr['Bob'] = 2;
$arr['Jane'] = 5;
foreach ($arr as $key => $value) {
echo $key.' has done it '.$value.' times<br />';
}
asort($arr);
print 'It is '.key($arr).'\'s turn';