Answers for "object array get last 3 records in php"

PHP
17

how to get last array element in php

<?php

$source_array = ['key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'];

$result = end($source_array);

echo "Last element: ".$result;

?>
Posted by: Guest on August-05-2020
1

php get all elements of array except last

$array = array( 1,2, 3 );
$sliced = array_slice($array, 0, -1); // array ( 1,2 )
Posted by: Guest on July-02-2021

Code answers related to "object array get last 3 records in php"

Browse Popular Code Answers by Language