1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-24 15:12:20 +01:00
Files
archived-doc-zh/reference/array/functions/array-is-list.xml
haytoo f8d2e5db81 新增 array_is_list 函数翻译 (#144)
* 新增 array_is_list 函数翻译

* 新增 array_is_list 函数翻译

* Update array-is-list.xml

Co-authored-by: DAI JIE <daijie@php.net>
2021-12-16 22:05:24 +08:00

113 lines
2.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 5ecd5e8e50f0f47dce7341ddc95334af62d9e770 Maintainer: haytoo Status: ready -->
<refentry xml:id="function.array-is-list" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>array_is_list</refname>
<refpurpose>判断给定的 <parameter>array</parameter> 是否为 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>
判断指定的 <parameter>array</parameter> 是否是 list。如果 &array; 的 key 由 <literal>0</literal><literal>count($array)-1</literal> 的连续数字组成,则该数组就是 list。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>array</parameter></term>
<listitem>
<para>
被检测的 &array;
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
如果 <parameter>array</parameter> 是 list 就返回 &true;,否则返回 &false;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>array_is_list</function> 示例</title>
<programlisting role="php">
<![CDATA[
<?php
array_is_list([]); // true
array_is_list(['apple', 2, 3]); // true
array_is_list([0 => 'apple', 'orange']); // true
// key 未从 0 开始
array_is_list([1 => 'apple', 'orange']); // false
// key 的顺序不正确
array_is_list([1 => 'apple', 0 => 'orange']); // false
// 包含非整数 key
array_is_list([0 => 'apple', 'foo' => 'bar']); // false
// 非连续 key
array_is_list([0 => 'apple', 2 => 'bar']); // false
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
空数组也会返回 &true;
</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
-->