php get last index end in foreach

39

php get last index end in foreach -

$numItems = count($arr);
$i = 0;
foreach($arr as $key=>$value) {
  if(++$i === $numItems) {
    echo "last index!";
  }
}    

Comments

Submit
0 Comments