php-doc-en/reference/array/functions/array-is-list.xml
Sergey Panteleev 5ecd5e8e50
[PHP 8.1] Add array_is_list description (#986)
Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
2021-10-02 19:52:56 +03:00

114 lines
2.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="function.array-is-list" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>array_is_list</refname>
<refpurpose>Checks whether a given <parameter>array</parameter> is a list</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>array_is_list</methodname>
<methodparam><type>array</type><parameter>array</parameter></methodparam>
</methodsynopsis>
<para>
Determines if the given <parameter>array</parameter> is a list.
An &array; is considered a list if its keys consist of consecutive numbers
from <literal>0</literal> to <literal>count($array)-1</literal>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>array</parameter></term>
<listitem>
<para>
The &array; being evaluated.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns &true; if <parameter>array</parameter> is a list, &false;
otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>array_is_list</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
array_is_list([]); // true
array_is_list(['apple', 2, 3]); // true
array_is_list([0 => 'apple', 'orange']); // true
// The array does not start at 0
array_is_list([1 => 'apple', 'orange']); // false
// The keys are not in the correct order
array_is_list([1 => 'apple', 0 => 'orange']); // false
// Non-integer keys
array_is_list([0 => 'apple', 'foo' => 'bar']); // false
// Non-consecutive keys
array_is_list([0 => 'apple', 2 => 'bar']); // false
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
This function returns &true; on empty arrays.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>array_values</function></member>
</simplelist>
</para>
</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
-->