PHP array_key_first() Function
The array_key_first() is an inbuilt function of PHP and is used to gets the first key of an array.
You can get the first key from given array without affecting the internal array pointer.
You can get the first key from given array without affecting the internal array pointer.
Syntax:
array_key_first(array)
Parameters:
array:
An array.
Returns the first key of
array
if the array is not empty; NULL
otherwise.
Simple Example:
<?php
$array = ['apple' => 1, 'banana' => 2, 'mango' => 3];
$first= array_key_first($array);
var_dump($first);
?>
Output:
string(5) "apple"
Leave a Comment