Re: [PHP] Array difficulty
- From: carlton.whitehead@xxxxxxxxxxxx (Carlton Whitehead)
- Date: Tue, 31 Jul 2007 09:48:29 -0400 (EDT)
I tried that earlier, but the problem is:
count( $chance ) - 1 ); returns an integer, so I would be asking for something like $chance[1] or $chance[0], neither of which exist in the array. Keep in mind $chance only has keys with string names:
The array looks like this:
$chance = array("lowercase" => 27, "uppercase" => 62, "integer" => 46);
The values assigned to each key are randomly generated.
Regards,
Carlton Whitehead
----- Original Message -----
From: "Chris Boget" <chris.boget@xxxxxxxx>
To: "Carlton Whitehead" <carlton.whitehead@xxxxxxxxxxxx>, php-general@xxxxxxxxxxxxx
Sent: Tuesday, July 31, 2007 9:43:00 AM (GMT-0500) America/New_York
Subject: RE: [PHP] Array difficulty
At this point, $result would be equal to "uppercase". I feel
like this is a really kludgey way to accomplish this. Is there
a better way?
Couldn't you just do
arsort($chance);
$lastItem = chance[( count( $chance ) - 1 )];
? Why iterate through the array when all you need is the last value?
thnx,
Chris
.
- Follow-Ups:
- Re: [PHP] Array difficulty
- From: "Alister Bulman"
- Re: [PHP] Array difficulty
- Prev by Date: Email a php webpage
- Next by Date: Re: [PHP] Re: Pirate PHP books online?
- Previous by thread: Email a php webpage
- Next by thread: Re: [PHP] Array difficulty
- Index(es):
Relevant Pages
|