The way I would like to approach this is to increase the increment of the variable and check this variable for the size of the array ( count()):
$i = 0;
$c = count($array);
foreach($array as $key => $value) {
$i++;
if ($i == $c) {
}
else {
}
}
This may, obviously, not be the most effective method.
source
share