1
0
mirror of https://github.com/php/doc-ru.git synced 2026-04-30 02:33:22 +02:00
Files
archived-doc-ru/reference/array/functions/array-fill.xml
T
2022-07-18 00:27:52 +03:00

187 lines
5.1 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: eaaf3a0b450ef688c5e80ba7d8cd97a771dc81cc Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<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>count</parameter></methodparam>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
Заполняет массив <parameter>count</parameter> элементами со значением
<parameter>value</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>, а последующие индексы
будут начинаться с нуля
(смотрите <link linkend="function.array-fill.example.basic">пример</link>).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>count</parameter></term>
<listitem>
<para>
Количество добавляемых элементов.
Должно быть больше или равно нулю и меньше или равно <literal>2147483647</literal>.
</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>
Выбрасывает исключение <classname>ValueError</classname> в случае, если
параметр <parameter>count</parameter> выходит за пределы диапазона.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0</entry>
<entry>
Функция <function>array_fill</function> теперь выбрасывает исключение <classname>ValueError</classname>,
если параметр <parameter>count</parameter> выходит за пределы диапазона;
ранее выдавалась ошибка уровня <constant>E_WARNING</constant>,
а функция возвращала значение &false;.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</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
-->