PHP.nl

array_first

array_first

Gets the first value of an array

mixed **array_first** array $array

Get the first value of the given . array

arrayAn array.

Returns the first value of if the array is not empty; null otherwise. array

Voorbeeld: Basic Usage

<?php
$array = [1 => 'a', 0 => 'b', 3 => 'c', 2 => 'd'];

$firstValue = array_first($array);

var_dump($firstValue);
?>
string(1) "a"

array_key_first``array_last