T
T
Talyan2018-03-24 03:21:55
PHP
Talyan, 2018-03-24 03:21:55

How to get the last key of an associative array with numeric keys?

<?
$array=array(2=> "two", 3=>"three", 5=>"five", 10=>"ten");
?>

как получить из массива последний ключ (10), не зная ключей?
<?
print $array[count($array)-1]; //выдаст "two" вместо "ten"
?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Alexandrov, 2018-03-24
@ImidgX

Alternatively: ;-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question