1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-24 07:42:22 +01:00
Files
archived-doc-ru/reference/array/functions/array-fill.xml
Mikhail Alferov 01fd1e80af Update reference/array/functions to En (#1068)
* Update book.xml to en

* Update array-combine.xml to en

* Update array-diff.xml to en

* Update array-fill.xml to en

* Update array-is-list.xml to en

* Update array-map.xml to en

* Update array-merge.xml to en

* Update array-multisort.xml to en

* Update array-pad.xml to en

* Update array-search.xml to en

* Update array-splice.xml to en

* Update array-udiff-uassoc.xml to en

* Update array.xml to en

* Update count.xml to en

* Update current.xml to en

* Update each.xml to en

* Update in-array.xml to en

* Update list.xml to en

* Update next.xml to en

* Update prev.xml to en

* Update usort.xml to en
2025-05-09 09:05:53 +03:00

224 lines
6.4 KiB
XML
Raw Permalink 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: 2e60c5134e7a847c99f81eb3f7ecee1f5efeeace 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>value</parameter>
столько раз, сколько указали в параметре <parameter>count</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>,
а следующие индексы до PHP 8.0.0 продолжаются с нуля;
начиная с PHP 8.0.0 отрицательные ключи увеличиваются последовательно,
как показывает <link linkend="function.array-fill.example.negative-start-index">пример</link>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>count</parameter></term>
<listitem>
<para>
Количество элементов, которое требуется вставить.
Параметр принимает значение, которое больше или равно нулю и меньше или равно <literal>2 147 483 647</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, 'банан');
print_r($a);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[5] => банан
[6] => банан
[7] => банан
[8] => банан
[9] => банан
[10] => банан
)
]]>
</screen>
</example>
</para>
<para>
<example xml:id="function.array-fill.example.negative-start-index">
<title>Пример использования функции <function>array_fill</function> с отрицательным начальным индексом</title>
<programlisting role="php">
<![CDATA[
<?php
$a = array_fill(-2, 4, 'груша');
print_r($a);
?>
]]>
</programlisting>
&example.outputs.8;
<screen>
<![CDATA[
Array
(
[-2] => груша
[-1] => груша
[0] => груша
[1] => груша
)
]]>
</screen>
&example.outputs.7;
<screen>
<![CDATA[
Array
(
[-2] => груша
[0] => груша
[1] => груша
[2] => груша
)
]]>
</screen>
</example>
</para>
<para>
Обратите внимание, вывод до PHP 8.0.0 не содержит индекса <literal>-1</literal>.
</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
-->