Author: Admin/Publisher |finished | checked
PHP array_key_last function
The PHP function array_key_last retrieves the last key of the array without affecting the pointer’s position within the array.
Description / Descripciónarray_key_last(array $array): int|string|null
Parameter
$array – the array from which we will get the last key.
Return
Returns the last key of the array if the array is not empty; otherwise, it will return null.
Example
In this case, we’ll use the same example we saw with array_key_first, but we’ll use array_key_last to find the key of the last element.
$marcasDeAutos = array(
"Toyota",
"Ford",
"Honda",
"Chevrolet",
"Volkswagen",
"BMW",
"Mercedes-Benz",
"Audi",
"Nissan",
"Hyundai",
"Kia",
"Subaru",
"Mazda",
"Lexus",
"Jeep",
);
echo(array_key_last($marcasDeAutos));
14
Category: en-php
Something wrong?
If you found an error or mistake in the content you can contact me on Twitter | @luisg2249_luis.

