array_first
Gets the first value of an array
Description
mixed array_first(array $array
)
Parameters
-
array
-
An array.
Return Values
Returns the first value of array
if the array is not empty;
null
otherwise.
Examples
Example #1 Basic array_first Usage
<?php
$array = [1 => 'a', 0 => 'b', 3 => 'c', 2 => 'd'];
$firstValue = array_first($array);
var_dump($firstValue);
?>
The above example will output:
See Also
- array_key_first
- array_last