Consider the following array.
$a['a'] = 1;
$a['b'] = 2;
$a['c'] = 3;
$a['d'] = 4;
and then i am looping the array
foreach( $a as $q => $x )
{
# Some operations ....
if( isLastElement == false ){
#Want to do some more operation
}
}
How can i know that the current position is last or not ?
Thanks.
countof your arraycount($a)will return the number of element in your array, so you can use an integer initialized to 0 before the loop increment it at each loop, and compare it with the count of the array. You will be able to know when you are on the last element.