1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-24 15:52:13 +01:00
Files
archived-doc-ru/reference/array/functions/array-pad.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

161 lines
5.2 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-pad" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>array_pad</refname>
<refpurpose>Дополняет массив значением до заданной длины</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>array_pad</methodname>
<methodparam><type>array</type><parameter>array</parameter></methodparam>
<methodparam><type>int</type><parameter>length</parameter></methodparam>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
Функция <function>array_pad</function> возвращает копию массива
<parameter>array</parameter>, который дополняет элементами
со значением <parameter>value</parameter> до заданного
в параметре <parameter>length</parameter> размера. Если параметр
<parameter>length</parameter> положителен, то функция дополняет массив
справа, если отрицателен — слева. Если абсолютное значение
параметра <parameter>length</parameter> меньше или равно
размеру массива <parameter>array</parameter>, функция не дополняет массив.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>array</parameter></term>
<listitem>
<para>
Исходный массив, который функция дополнит значениями.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>length</parameter></term>
<listitem>
<para>
Новый размер массива.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
Значение для дополнения, если длина массива <parameter>array</parameter>
меньше значения параметра <parameter>length</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Функция возвращает копию массива <parameter>array</parameter>, который дополняет
до заданного в параметре <parameter>length</parameter> размера значением
<parameter>value</parameter>. Если параметр
<parameter>length</parameter> положителен, то функция дополняет массив
справа, если отрицателен — слева.
Если абсолютное значение параметра <parameter>length</parameter> меньше или равно
размеру массива <parameter>array</parameter>, функция не выполняет операций.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.3.0</entry>
<entry>
До PHP 8.3 можно было добавить не более 1 048 576 элементов.
Теперь это ограниченно только размером массива.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример дополнения массива функцией <function>array_pad</function></title>
<programlisting role="php">
<![CDATA[
<?php
$input = array(12, 10, 9);
$result = array_pad($input, 5, 0);
// результат: array(12, 10, 9, 0, 0)
echo join(', ', $result), PHP_EOL;
$result = array_pad($input, -7, -1);
// Результат: array(-1, -1, -1, -1, 12, 10, 9)
echo join(', ', $result), PHP_EOL;
$result = array_pad($input, 2, "noop");
// Операция не выполнена
echo join(', ', $result), PHP_EOL;
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>array_fill</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
-->