There is finally some useful 7.3 features for arrays! Introducing array_key_first()
and array_key_last()
.
There are new functions added to array package: array_key_first()
and array_key_last()
for getting the first or last key of the array. This is extremely useful when the array is not an index based one and we don’t know its keys. These functions will not affect the internal array pointer.
$array = ['a' => 1, 'b' => 2, 'c' => 3]; echo array_key_first($array); echo array_key_last($array); //will return a c
Reference
PHP 7 News & Updates v7.0 – 7.4 Book https://www.amazon.com/PHP-News-Updates-v7-0-7-4/dp/1727202481/
Rate this artcile
[Total: 1 Average: 5]
Great info. Lucky me I recently found your blog by chance.
I have saved it for later!
Sustain the remarkable work !! Lovin’ it!