Answered by : handsome-hamerkop-98vnd2asf8do
<?php
$source_array = ['key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'];
$result = end($source_array);
echo "Last element: ".$result;
?>
Source : https://www.gtechhub.com/blog/programming-code/php-hypertext-preprocessor/get-the-last-element-of-an-array-in-php-end | Last Update : Wed, 12 Aug 20
Answered by : rich-raccoon-8rvxrv8b4asw
<?php
$source_array = [ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'
];
echo "Last index: " . array_key_last($source_array);
?>
Source : | Last Update : Fri, 16 Apr 21
Answered by :
$array = array(5,6,70,10,36,2);
echo $array[count($array) -2];
Source : | Last Update : Thu, 27 May 21
Answered by : kevin-decena
$array = ['key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'];
$result = end($array);
Source : https://www.gtechhub.com/blog/programming-code/php-hypertext-preprocessor/get-the-last-element-of-an-array-in-php-end | Last Update : Wed, 15 Jun 22
Answered by : irfan-majid
end(array[]);
Source : | Last Update : Tue, 31 May 22
Answered by : matteo-puppis
array_slice($a, -3, 3, true);
Source : https://stackoverflow.com/questions/5468912/php-get-the-last-3-elements-of-an-associative-array-while-preserving-the-keys | Last Update : Fri, 15 Jul 22