array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'function.array-first.php', 1 => 'array_first', 2 => 'Gets the first value of an array', ), 'up' => array ( 0 => 'ref.array.php', 1 => 'Dizi İşlevleri', ), 'prev' => array ( 0 => 'function.array-find-key.php', 1 => 'array_find_key', ), 'next' => array ( 0 => 'function.array-flip.php', 1 => 'array_flip', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/array/functions/array-first.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

array_first

(PHP 8 >= 8.5.0)

array_firstGets the first value of an array

Açıklama

array_first(array $array): mixed

Get the first value of the given array.

Bağımsız Değişkenler

array
An array.

Dönen Değerler

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

Örnekler

Örnek 1 Basic array_first() Usage

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

$firstValue = array_first($array);

var_dump($firstValue);
?>

Yukarıdaki örneğin çıktısı:

string(1) "a"

Ayrıca Bakınız