update page now
PHP 8.1.34 Released!

array_first

(PHP 8 >= 8.5.0)

array_firstGets the first value of an array

Descrizione

array_first(array $array): mixed

Get the first value of the given array.

Elenco dei parametri

array
An array.

Valori restituiti

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

Esempi

Example #1 Basic array_first() Usage

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

$firstValue = array_first($array);

var_dump($firstValue);
?>

Il precedente esempio visualizzerà:

string(1) "a"

Vedere anche:

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant