Answers for "php 7 ans for getting last element in array using loop"

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 "php 7 ans for getting last element in array using loop"

Browse Popular Code Answers by Language