[doc-en] master: [PHP 8.5] added array_[first|last] Documentation (#4925)

From: Date: Mon, 13 Oct 2025 19:04:42 +0000
Subject: [doc-en] master: [PHP 8.5] added array_[first|last] Documentation (#4925)
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-22803@lists.php.net to get a copy of this message
Author: Yoshinari Takaoka (mumumu) Committer: GitHub (web-flow) Pusher: mumumu Date: 2025-10-14T04:04:40+09:00 Commit: https://github.com/php/doc-en/commit/85c47f89f35f927d7c7ad23235c830dc4b514ddd Raw diff: https://github.com/php/doc-en/commit/85c47f89f35f927d7c7ad23235c830dc4b514ddd.diff [PHP 8.5] added array_[first|last] Documentation (#4925) Changed paths: A reference/array/functions/array-first.xml A reference/array/functions/array-last.xml M reference/array/functions/array-key-first.xml M reference/array/functions/array-key-last.xml M reference/array/versions.xml Diff: 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<refentry xml:id="function.array-first" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + <refnamediv> + <refname>array_first</refname> + <refpurpose>Gets the first value of an array</refpurpose> + </refnamediv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type>mixed</type><methodname>array_first</methodname> + <methodparam><type>array</type><parameter>array</parameter></methodparam> + </methodsynopsis> + <para> + Get the first value of the given <parameter>array</parameter>. + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <variablelist> + <varlistentry> + <term><parameter>array</parameter></term> + <listitem> + <para> + An array. + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + Returns the first value of <parameter>array</parameter> if the array is not empty; + &null; otherwise. + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example xml:id="array_first.example.basic"> + <title>Basic <function>array_first</function> Usage</title> + <programlisting role="php"> +<![CDATA[ +<?php +$array = [1 => 'a', 0 => 'b', 3 => 'c', 2 => 'd']; + +$firstValue = array_first($array); + +var_dump($firstValue); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +string(1) "a" +]]> + </screen> + </example> + </para> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <simplelist> + <member><function>array_key_first</function></member> + <member><function>array_last</function></member> + </simplelist> + </refsect1> + +</refentry> +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"~/.phpdoc/manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> 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')) { <refsect1 role="seealso"> &reftitle.seealso; <simplelist> + <member><function>array_first</function></member> <member><function>array_key_last</function></member> <member><function>reset</function></member> </simplelist> 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 @@ <refsect1 role="seealso"> &reftitle.seealso; <simplelist> + <member><function>array_last</function></member> <member><function>array_key_first</function></member> <member><function>end</function></member> </simplelist> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<refentry xml:id="function.array-last" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + <refnamediv> + <refname>array_last</refname> + <refpurpose>Gets the last value of an array</refpurpose> + </refnamediv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type>mixed</type><methodname>array_last</methodname> + <methodparam><type>array</type><parameter>array</parameter></methodparam> + </methodsynopsis> + <para> + Get the last value of the given <parameter>array</parameter>. + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <variablelist> + <varlistentry> + <term><parameter>array</parameter></term> + <listitem> + <para> + An array. + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + Returns the last value of <parameter>array</parameter> if the array is not empty; + &null; otherwise. + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example xml:id="array_last.example.basic"> + <title>Basic <function>array_last</function> Usage</title> + <programlisting role="php"> +<![CDATA[ +<?php +$array = [1 => 'a', 0 => 'b', 3 => 'c', 2 => 'd']; + +$lastValue = array_last($array); + +var_dump($lastValue); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +string(1) "d" +]]> + </screen> + </example> + </para> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <simplelist> + <member><function>array_key_last</function></member> + <member><function>array_first</function></member> + </simplelist> + </refsect1> + +</refentry> +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"~/.phpdoc/manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> 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 @@ <function name='array_filter' from='PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8'/> <function name='array_find' from='PHP 8 &gt;= 8.4.0'/> <function name='array_find_key' from='PHP 8 &gt;= 8.4.0'/> + <function name='array_first' from='PHP 8 &gt;= 8.5.0'/> <function name='array_flip' from='PHP 4, PHP 5, PHP 7, PHP 8'/> <function name='array_intersect' from='PHP 4 &gt;= 4.0.1, PHP 5, PHP 7, PHP 8'/> <function name='array_intersect_assoc' from='PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8'/> @@ -33,6 +34,7 @@ <function name='array_key_first' from='PHP 7 &gt;= 7.3.0, PHP 8'/> <function name='array_key_last' from='PHP 7 &gt;= 7.3.0, PHP 8'/> <function name='array_keys' from='PHP 4, PHP 5, PHP 7, PHP 8'/> + <function name='array_last' from='PHP 8 &gt;= 8.5.0'/> <function name='array_map' from='PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8'/> <function name='array_merge' from='PHP 4, PHP 5, PHP 7, PHP 8'/> <function name='array_merge_recursive' from='PHP 4 &gt;= 4.0.1, PHP 5, PHP 7, PHP 8'/>

« previous php.doc.cvs (#22803) next »