Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php get first last loop

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

    if ($key === array_key_last($array)) {
        echo 'LAST ELEMENT!';
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: wp wc get cart item attribute 
Php :: array filter use key 
Php :: how to use required_with in laravel to array element 
Php :: artisan cache clear 
Php :: convert object to array laravel 
Php :: laravel add timestamps to existing table 
Php :: php download rate limit 
Php :: laravel get next record 
Php :: wordpress get user by id 
Php :: pdo turn on errors 
Php :: php get environment variable 
Php :: laravel select all except some columns 
Php :: laravel meta csrf 
Php :: wordpress get perma link 
Php :: PHP | get client ip 
Php :: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/Cellar/composer/1.9.1/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223 mac 
Php :: datetime iso 8601 php 
Php :: php elseif 
Php :: boot method laravel life cycle 
Php :: laravel new model 
Php :: check file selected in php 
Php :: php prime numbers 
Php :: laravel blade file naming conventine 
Php :: php get array key by value multidimensional 
Php :: PHP Warning: Version warning: Imagick was compiled against Image Magick version 1654 but version 1650 is loaded. 
Php :: Missing expression. (near "ON" at position 25) 
Php :: php clean all output buffers 
Php :: php version compare function 
Php :: get table name from model laravel 
Php :: Obtener datos de usuario registrado en WordPress 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =