Answers for "how to get a key value of last array in php"

PHP
1

key of last element php

//(PHP 7 >= 7.3.0)
$key = array_key_last($data);

//ALL PHP Versions
end($data);         // move the internal pointer to the end of the array
$key = key($data);  // fetches the key of the element pointed to by the internal pointer
Posted by: Guest on April-01-2020
2

php last item of array

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

Code answers related to "how to get a key value of last array in php"

Browse Popular Code Answers by Language