(PHP 8 >= 8.5.0)
array_first — Obtiene el primer valor de un array
array
Un array.
Devuelve el primer valor de array
si el array no está vacío;
null
en caso contrario.
Ejemplo #1 Uso básico de array_first()
<?php
$array = [1 => 'a', 0 => 'b', 3 => 'c', 2 => 'd'];
$firstValue = array_first($array);
var_dump($firstValue);
?>
El ejemplo anterior mostrará :
string(1) "a"