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-combine.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

158 lines
4.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: irker Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.array-combine" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>array_combine</refname>
<refpurpose>Создаёт новый массив с ключами из значений одного массива и значениями из значений другого</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>array_combine</methodname>
<methodparam><type>array</type><parameter>keys</parameter></methodparam>
<methodparam><type>array</type><parameter>values</parameter></methodparam>
</methodsynopsis>
<para>
Функция создаёт новый массив (<type>array</type>), в котором ключами становятся
значения массива <parameter>keys</parameter>,
а значениями — значения массива <parameter>values</parameter> в том же порядке.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>keys</parameter></term>
<listitem>
<para>
Массив ключей. Недопустимые значения ключей
преобразуются в значение с типом <type>string</type>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>values</parameter></term>
<listitem>
<para>
Массив значений.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Функция возвращает объединенный массив (<type>array</type>).
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Начиная с PHP 8.0.0 функция выбрасывает ошибку <classname>ValueError</classname>,
если количество элементов в массивах <parameter>keys</parameter> и <parameter>values</parameter>
не совпадает.
До PHP 8.0.0 вместо этого выдавалась ошибка уровня <constant>E_WARNING</constant>.
</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_combine</function> теперь выбрасывает ошибку <classname>ValueError</classname>,
если количество элементов в массивах не совпадает; раньше функция возвращала значение &false;.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Простой пример объединения массивов функцией <function>array_combine</function></title>
<programlisting role="php">
<![CDATA[
<?php
$a = array('green', 'red', 'yellow');
$b = array('avocado', 'apple', 'banana');
$c = array_combine($a, $b);
print_r($c);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[green] => avocado
[red] => apple
[yellow] => banana
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>array_merge</function></member>
<member><function>array_walk</function></member>
<member><function>array_values</function></member>
<member><function>array_map</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
-->