1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-23 23:32:18 +01:00

[PHP 8.5] added array_[first|last] Documentation (#4925)

This commit is contained in:
Yoshinari Takaoka
2025-10-14 04:04:40 +09:00
committed by GitHub
parent 2466135731
commit 85c47f89f3
5 changed files with 194 additions and 0 deletions

View File

@@ -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
-->

View File

@@ -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>

View File

@@ -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>

View File

@@ -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
-->

View File

@@ -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'/>