[PHP] Last Element in an Array?

2001-04-19 Thread Jason Caldwell
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

Re: [PHP] Last Element in an Array?

2001-04-19 Thread Rasmus Lerdorf
What are you trying to do? -Rasmus On Thu, 19 Apr 2001, 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

Re: [PHP] Last Element in an Array?

2001-04-19 Thread Andrew Hill
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))

RE: [PHP] Last Element in an Array?

2001-04-19 Thread ..s.c.o.t.t..
$a is $a[2]; -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 19, 2001 17:08 To: Jason Caldwell Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Last Element in an Array? Jason, You can use array_pop() to return the last element of the array -