mirror of
https://github.com/php/doc-es.git
synced 2026-03-25 16:02:13 +01:00
Adoptando otros git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@167065 c90b9560-bf6c-de11-be94-00142212c4b1
103 lines
2.9 KiB
XML
103 lines
2.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.2 $ -->
|
|
<!-- EN-Revision: 1.11 Maintainer: baoengb Status: ready -->
|
|
<!-- splitted from ./es/functions/array.xml, last change in rev 1.1 -->
|
|
<refentry id="function.array-flip">
|
|
<refnamediv>
|
|
<refname>array_flip</refname>
|
|
<refpurpose>Intercambia los valores de una matriz con sus índices</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descripción</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_flip</methodname>
|
|
<methodparam><type>array</type><parameter>trans</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_flip</function> devuelve una matriz con los valores intercambiados,
|
|
por ejemplo los índices de <parameter>trans</parameter> se convierten
|
|
en los valores y los valores de <parameter>trans</parameter> se convierten
|
|
en los índices.
|
|
</para>
|
|
<para>
|
|
note que los valores de <parameter>trans</parameter> necesitan ser índices
|
|
validos, eg. necesitan ser del tipo <type>integer</type> o <type>string</type>.
|
|
Se generará una alerta si un valor tiene un tipo diferente, y el
|
|
par índice/valor en cuestión <emphasis>no será
|
|
modificado</emphasis>.
|
|
</para>
|
|
<para>
|
|
Si un valor se encuentra varias veces, el último índice
|
|
será usado con su valor, y todos los demás se perderán
|
|
</para>
|
|
<para>
|
|
<function>array_flip</function> regresa &false; su falla.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>array_flip</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$trans = array_flip($trans);
|
|
$original = strtr($str, $trans);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de colisión con <function>array_flip</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$trans = array("a" => 1, "b" => 1, "c" => 2);
|
|
$trans = array_flip($trans);
|
|
print_r($trans);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
ahora <varname>$trans</varname> es:
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[1] => b
|
|
[2] => c
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Vea también <function>array_values</function>,
|
|
<function>array_keys</function>, y
|
|
<function>array_reverse</function>.
|
|
</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:"../../../../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
|
|
-->
|