Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how get end of array in foreach php

$last_key = end(array_keys($array));
foreach ($array as $key => $value) {
    if ($key == $last_key) {
        // last element
    } else {
        // not last element
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to register a file in a config in laravel 
Php :: radio button in php form 
Php :: wordpress set category front end 
Php :: import csv laravel 
Php :: how i can send by database table in laravel full calendar 
Php :: wordpress get post type from url 
Php :: Befreie den WordPress-Header von unnötigen Einträgen 
Php :: laravel how to address to git repo for develop packages 
Php :: Initialisez un tableau de 4 cases (contenant des nombres) et en faire la somme en créant une fonction somme php 
Php :: php blade first child @foreach 
Php :: php preg_match html cross origin 
Php :: Validate checkboxes laravel 
Php :: how to remove payment link in invoice woocommerce 
Php :: Issue with Generating Random Numbers using Laravel contains vs foreach loop 
Php :: import facade laravel 
Php :: Laravel Dropzone Attachment Required is not working as expected 
Php :: php curl get text only 
Php :: Formatting an Excel Column 
Php :: how-to-add-pagination-in-search-results wordpress 
Php :: php file structure 
Php :: Automatically downloading images from any URL location 
Php :: developer polyglots 
Php :: create newfilter wordpress 
Php :: returning two yajra datatable using single method on the sam view laravel 
Php :: how to fetch group name in custom post type in wordpress 
Php :: standalone laravel orm 
Php :: html vs php 
Php :: Add “Affected Products” in catalog price rule 
Php :: check if date is older than today php 
Php :: php preg_replace callback 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =