1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-26 08:42:13 +01:00
Files
archived-doc-ru/reference/array/functions/array-flip.xml
Sergey Panteleev 6afc62ce7d docs(ru): Updated to English revision
git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@351745 c90b9560-bf6c-de11-be94-00142212c4b1
2020-11-29 10:58:56 +00:00

146 lines
4.0 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: e41806c30bf6975e452c0d4ce35ab0984c2fa68c Maintainer: shein Status: ready -->
<!-- Reviewed: yes -->
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.array-flip">
<refnamediv>
<refname>array_flip</refname>
<refpurpose>Меняет местами ключи с их значениями в массиве</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>array_flip</methodname>
<methodparam><type>array</type><parameter>array</parameter></methodparam>
</methodsynopsis>
<para>
Функция <function>array_flip</function> возвращает массив (<type>array</type>)
наоборот, то есть ключи массива <parameter>array</parameter> становятся значениями,
а значения массива <parameter>array</parameter> становятся ключами.
</para>
<para>
Обратите внимание, что значения массива <parameter>array</parameter>
должны быть корректными ключами, то есть они должны иметь тип
<type>int</type> или <type>string</type>.
Если значение имеет неверный тип, будет выдано предупреждение
и данная пара ключ/значение <emphasis>не будет включена
в результат</emphasis>.
</para>
<para>
Если значение встречается несколько раз, для обработки
будет использоваться последний встреченный ключ, а
все остальные будут потеряны.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>array</parameter></term>
<listitem>
<para>
Массив переворачиваемых пар ключ/значение.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Возвращает перевернутый массив в случае успеха и &null; в случае ошибки.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>array_flip</function></title>
<programlisting role="php">
<![CDATA[
<?php
$input = array("oranges", "apples", "pears");
$flipped = array_flip($input);
print_r($flipped);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[oranges] => 0
[apples] => 1
[pears] => 2
)
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Пример использования <function>array_flip</function> с коллизиями</title>
<programlisting role="php">
<![CDATA[
<?php
$input = array("a" => 1, "b" => 1, "c" => 2);
$flipped = array_flip($input);
print_r($flipped);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[1] => b
[2] => c
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>array_values</function></member>
<member><function>array_keys</function></member>
<member><function>array_reverse</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
-->