From aba72afe3b19f50f8f4308b2d5275fce54cd477e Mon Sep 17 00:00:00 2001 From: Yoshinari Takaoka Date: Mon, 13 Oct 2025 23:23:01 +0900 Subject: [PATCH 1/2] [PHP 8.5] added array_[first|last] Documentation --- reference/array/functions/array-first.xml | 95 +++++++++++++++++++++++ reference/array/functions/array-last.xml | 95 +++++++++++++++++++++++ reference/array/versions.xml | 2 + 3 files changed, 192 insertions(+) create mode 100644 reference/array/functions/array-first.xml create mode 100644 reference/array/functions/array-last.xml diff --git a/reference/array/functions/array-first.xml b/reference/array/functions/array-first.xml new file mode 100644 index 000000000000..f661cb6d1826 --- /dev/null +++ b/reference/array/functions/array-first.xml @@ -0,0 +1,95 @@ + + + + array_first + Gets the first value of an array + + + + &reftitle.description; + + mixedarray_first + arrayarray + + + Get the first value of the given array. + + + + + &reftitle.parameters; + + + array + + + An array. + + + + + + + + &reftitle.returnvalues; + + Returns the first value of array if the array is not empty; + &null; otherwise. + + + + + &reftitle.examples; + + + Basic <function>array_first</function> Usage + + 'a', 0 => 'b', 3 => 'c', 2 => 'd']; + +$firstValue = array_first($array); + +var_dump($firstValue); +?> +]]> + + &example.outputs; + + + + + + + + + &reftitle.seealso; + + array_key_first + array_last + + + + + diff --git a/reference/array/functions/array-last.xml b/reference/array/functions/array-last.xml new file mode 100644 index 000000000000..5684416750e5 --- /dev/null +++ b/reference/array/functions/array-last.xml @@ -0,0 +1,95 @@ + + + + array_last + Gets the last value of an array + + + + &reftitle.description; + + mixedarray_last + arrayarray + + + Get the last value of the given array. + + + + + &reftitle.parameters; + + + array + + + An array. + + + + + + + + &reftitle.returnvalues; + + Returns the last value of array if the array is not empty; + &null; otherwise. + + + + + &reftitle.examples; + + + Basic <function>array_last</function> Usage + + 'a', 0 => 'b', 3 => 'c', 2 => 'd']; + +$lastValue = array_last($array); + +var_dump($lastValue); +?> +]]> + + &example.outputs; + + + + + + + + + &reftitle.seealso; + + array_key_last + array_first + + + + + diff --git a/reference/array/versions.xml b/reference/array/versions.xml index 39a5e36c7732..8017e8852e16 100644 --- a/reference/array/versions.xml +++ b/reference/array/versions.xml @@ -22,6 +22,7 @@ + @@ -33,6 +34,7 @@ + From 6e0ec64eebd39324fa6e5083d388b0624d149639 Mon Sep 17 00:00:00 2001 From: Yoshinari Takaoka Date: Tue, 14 Oct 2025 03:24:15 +0900 Subject: [PATCH 2/2] added link back from array_key_[first|last] page. --- reference/array/functions/array-key-first.xml | 1 + reference/array/functions/array-key-last.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/reference/array/functions/array-key-first.xml b/reference/array/functions/array-key-first.xml index 85f8ea428805..64cac0f8773b 100644 --- a/reference/array/functions/array-key-first.xml +++ b/reference/array/functions/array-key-first.xml @@ -98,6 +98,7 @@ if (!function_exists('array_key_first')) { &reftitle.seealso; + array_first array_key_last reset diff --git a/reference/array/functions/array-key-last.xml b/reference/array/functions/array-key-last.xml index 8137e78fe141..276203f2217c 100644 --- a/reference/array/functions/array-key-last.xml +++ b/reference/array/functions/array-key-last.xml @@ -43,6 +43,7 @@ &reftitle.seealso; + array_last array_key_first end