The question is simple. I have a foreach
loop in my code:
foreach($array as $element) {
//code
}
In this loop, I want to r
Simply this works!
// Set the array pointer to the last key
end($array);
// Store the last key
$lastkey = key($array);
foreach($array as $key => $element) {
....do array stuff
if ($lastkey === key($array))
echo 'THE LAST ELEMENT! '.$array[$lastkey];
}
Thank you @billynoah for your sorting out the end issue.