mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 15:32:36 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@302640 c90b9560-bf6c-de11-be94-00142212c4b1
190 lines
5.5 KiB
XML
190 lines
5.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 297028 $ -->
|
|
<!-- EN-Revision: 96c9d88bad9a7d7d44bfb7f26c226df7ee9ddf26 Maintainer: seros Status: ready -->
|
|
<refentry xml:id="function.array-replace-recursive" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_replace_recursive</refname>
|
|
<refpurpose>Reemplaza los elementos de los arrays pasados al primer array de forma recursiva</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_replace_recursive</methodname>
|
|
<methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter role="reference">array1</parameter></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter role="reference">array2</parameter></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter role="reference">...</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_replace_recursive</function> reemplaza los valores del primer
|
|
<parameter>array</parameter> con los mismos valores de todos los siguientes
|
|
arrays. Si una clave del primer array existe en el segundo array, su valor
|
|
será reemplazado por el valor del segundo array. Si la clave existe en el
|
|
segundo array, y no en el tercero, será creada en el primer array.
|
|
Si una clave existe unícamente en el primer array, se dejdará como está.
|
|
Si se pasan varios array para el reemplazamiento, serán procesados
|
|
en orden, el último array sobrescribiendo los valores anteriores.
|
|
</para>
|
|
<para>
|
|
<function>array_replace_recursive</function> es recursiva: hará recursión en los
|
|
arrays y aplicará el mismo proceso al valor interno.
|
|
</para>
|
|
<para>
|
|
Cuando el valor de <parameter>array</parameter> es escalar, será reemplazado
|
|
por el valor de <parameter>array1</parameter>, que puede ser escalar o un array.
|
|
Cuando el valore de <parameter>array</parameter> y <parameter>array1</parameter>
|
|
son arrays, <function>array_replace_recursive</function> reemplazará
|
|
sus respectivos valores recursivamente.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El array en el que los elementos son reemplazados.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>array1</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El array del que se extraen los elementos.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve un <type>array</type>, o &null; en caso de error.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>array_replace_recursive</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$base = array('cítricos' => array( "naranja") , 'bayas' => array("mora", "frambuesa"), );
|
|
$reemplazamientos = array('cítricos' => array('piña'), 'bayas' => array('arándano'));
|
|
|
|
$cesta = array_replace_recursive($base, $reemplazamientos);
|
|
print_r($cesta);
|
|
|
|
$cesta = array_replace($base, $reemplazamientos);
|
|
print_r($cesta);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[cítricos] => Array
|
|
(
|
|
[0] => piña
|
|
)
|
|
|
|
[bayas] => Array
|
|
(
|
|
[0] => arándano
|
|
[1] => frambuesa
|
|
)
|
|
|
|
)
|
|
Array
|
|
(
|
|
[cítricos] => Array
|
|
(
|
|
[0] => piña
|
|
)
|
|
|
|
[bayas] => Array
|
|
(
|
|
[0] => arándano
|
|
)
|
|
|
|
)
|
|
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<example>
|
|
<title><function>array_replace_recursive</function> y comportamiento recursivo</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$base = array('cítricos' => array("naranja") , 'bayas' => array("mora", "frambuesa"), 'otros' => 'banana' );
|
|
$reemplazamientos = array('cítricos' => 'piña', 'bayas' => array('arándano'), 'otros' => array('litchis'));
|
|
$reemplazamientos2 = array('cítricos' => array('piña'), 'bayas' => array('arándano'), 'otros' => 'litchis');
|
|
|
|
$cesta = array_replace_recursive($base, $reemplazamientos, $reemplazamientos2);
|
|
print_r($cesta);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[cítricos] => Array
|
|
(
|
|
[0] => piña
|
|
)
|
|
|
|
[bayas] => Array
|
|
(
|
|
[0] => arándano
|
|
[1] => frambuesa
|
|
)
|
|
|
|
[otros] => litchis
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>array_replace</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
|
|
-->
|