Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php foreach first element

foreach($array as $key => $element) {
    if ($key === array_key_first($array))
        echo 'FIRST ELEMENT!';

    if ($key === array_key_last($array))
        echo 'LAST ELEMENT!';
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #foreach #element
ADD COMMENT
Topic
Name
7+6 =