Answers for "Why does my php foreach loop return only the last value of the array?"

PHP
1

php foreach if last item

$numItems = count($arr);
$i = 0;
foreach($arr as $key=>$value) {
  if(++$i === $numItems) {
    echo "last index!";
  }
}
Posted by: Guest on May-19-2020

Code answers related to "Why does my php foreach loop return only the last value of the array?"

Browse Popular Code Answers by Language