Answers for "how to operate in foreach first element with second element 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 "how to operate in foreach first element with second element php"

Browse Popular Code Answers by Language