Skip to content

Instantly share code, notes, and snippets.

@qwersk
Created March 29, 2017 04:22
Show Gist options
  • Save qwersk/3830156bba377adeb298e20bc6788408 to your computer and use it in GitHub Desktop.
Save qwersk/3830156bba377adeb298e20bc6788408 to your computer and use it in GitHub Desktop.
CHECK LAST ELEMENT IN ARRAY PHP
$numItems = count($arr);
$i = 0;
foreach($arr as $key=>$value) {
if(++$i === $numItems) {
echo "last index!";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment