Re: Last Element in an Array?
| From: | Andrew Hill | Date: | Fri, 20 Apr 2001 00:07:54 +0000 |
| Subject: | Re: Last Element in an Array? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49453@lists.php.net to get a copy of this message | ||
Jason,
You can use array_pop() to return the last element of the array -
$last_item = array_pop ($array);
but if you just want your array processing to stop when it's reached the last item in the array (and avoid the loop) then do something like:
while (list ($var1, $var2) = each ($array))
HTH!
Best regards,
Andrew
--------------------------------------------
Andrew Hill - OpenLink Software
Directory of Technology Evangelism
Internet Data Integration Technology
http://www.openlinksw.com
On Thursday, April 19, 2001, at 07:57 PM, Jason Caldwell wrote:
Is there a command which will tell me that it is the last in an array? When I use END it just gives me the value IN the array... I want to know when I hit the last element in an array... This is driving me crazy... Thanks. Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net