How to point last element of an array in PHP?
How to point last element of an array in PHP?
Hi, While learning PHP programming & applications, I encountered an issue where I need to point last element of an array in PHP. I have searched in many (DELETED) for this solutions but still issue remains the same. Hoping to get a solution from the fellow tech experts.
- zend_eyalt
- Posts: 285
- Joined: Thu Jan 22, 2009 3:16 pm
Re: How to point last element of an array in PHP?
thnks for supporting :)
Re: How to point last element of an array in PHP?
$ Total = count ($ array);ashi4275 wrote:Hi, While learning PHP programming & applications, I encountered an issue where I need to point last element of an array in PHP. I have searched in many (DELETED) for this solutions but still issue remains the same. Hoping to get a solution from the fellow tech experts.
$ Counter = 0;
Foreach ($ array as $ key => value) {
$ Counter ++;
If ($ counter == $ total) {
// do something with the last element ...
}
Else {
// do something with element
}
}