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.

Carlton Whitehead

----- Original Message -----
From: "Chris Boget" <[EMAIL PROTECTED]>
To: "Carlton Whitehead" <[EMAIL PROTECTED]>, php-general@lists.php.net
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

$lastItem = chance[( count( $chance ) - 1 )];

?  Why iterate through the array when all you need is the last value?


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to