Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<array_find_keyarray_flip>
^Array FunctionsLast updated: Mon, 26 Oct 2026

array_first

(PHP 8 >= 8.5.0)

array_first — Gets the first value of an array

Description

function array_first(array $array): mixed

Get the first value of the given 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:

string(1) "a"

See Also


<array_find_keyarray_flip>
^Array FunctionsLast updated: Mon, 26 Oct 2026