Answers for "first element of array foreach php"

PHP
1

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!';
}
Posted by: Guest on July-02-2021

Code answers related to "first element of array foreach php"

Browse Popular Code Answers by Language