mirror of
https://github.com/php/doc-zh.git
synced 2026-04-26 01:28:18 +02:00
c35cf0459d
git-svn-id: https://svn.php.net/repository/phpdoc/zh/trunk@333718 c90b9560-bf6c-de11-be94-00142212c4b1
162 lines
4.0 KiB
XML
Executable File
162 lines
4.0 KiB
XML
Executable File
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- $Author$ -->
|
|
<!-- EN-Revision: 1bdcb1b9fdcaf92904fc4fdb0d89e1a37159665e Maintainer: dallas Status: ready -->
|
|
<refentry xml:id="function.array-fill" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_fill</refname>
|
|
<refpurpose>用给定的值填充数组</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_fill</methodname>
|
|
<methodparam><type>int</type><parameter>start_index</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>num</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_fill</function> 用 <parameter>value</parameter>
|
|
参数的值将一个数组填充 <parameter>num</parameter> 个条目,键名由
|
|
<parameter>start_index</parameter> 参数指定的开始。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
<term><parameter>start_index</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
返回的数组的第一个索引值。
|
|
</para>
|
|
<para>
|
|
如果 <parameter>start_index</parameter> 是负数,
|
|
那么返回的数组的第一个索引将会是
|
|
<parameter>start_index</parameter> ,而后面索引则从0开始。
|
|
(参见 <link linkend="function.array-fill.example.basic">例子</link>)。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><parameter>num</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
插入元素的数量。
|
|
必须大于 0。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><parameter>value</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
用来填充的值。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
返回填充后的数组。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
如果 <parameter>num</parameter> 少于一个,将会抛出 <constant>E_WARNING</constant>。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example xml:id="function.array-fill.example.basic">
|
|
<title><function>array_fill</function> 例子</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$a = array_fill(5, 6, 'banana');
|
|
$b = array_fill(-2, 4, 'pear');
|
|
print_r($a);
|
|
print_r($b);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[5] => banana
|
|
[6] => banana
|
|
[7] => banana
|
|
[8] => banana
|
|
[9] => banana
|
|
[10] => banana
|
|
)
|
|
Array
|
|
(
|
|
[-2] => pear
|
|
[0] => pear
|
|
[1] => pear
|
|
[2] => pear
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<para>
|
|
参见手册上 <link linkend="language.types.array">数组</link> 一节里关于负数的键的详细解释。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>array_fill_keys</function></member>
|
|
<member><function>str_repeat</function></member>
|
|
<member><function>range</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
|
|
-->
|