Answers for "array last index 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 index of last element in array

<?php

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

echo "Last index: " . array_key_last($source_array);

?>
Posted by: Guest on April-09-2021
2

php last item of array

echo end(['Gon', 'Killua', 'Hisoka']) // print Hisoka
Posted by: Guest on January-31-2021

Browse Popular Code Answers by Language