Created
September 16, 2015 15:47
-
-
Save jandrodev/e55db758c9d8069f1a72 to your computer and use it in GitHub Desktop.
Comprobar si estamos en el primer/último elemento de un array PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach($miArray as $elem) { | |
if ($elem === end($miArray)) { | |
echo "ÚLTIMO ELEMENTO"; | |
} | |
if ($elem === reset($miArray)) { | |
echo "PRIMER ELEMENTO"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment