mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 07:22:16 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@349887 c90b9560-bf6c-de11-be94-00142212c4b1
190 lines
5.0 KiB
XML
190 lines
5.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: b7a1a91f896ad48619d023d074f10ba69a514160 Maintainer: seros Status: ready -->
|
|
<!-- Reviewed: yes Maintainer: seros -->
|
|
<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>array1</parameter></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter>...</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_replace_recursive</function> reemplaza los valores de
|
|
<parameter>array1</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 primero, será creada en el primer array.
|
|
Si una clave existe únicamente en el primer array, se dejará como está.
|
|
Si se pasan varios arrays para el reemplazo, serán procesados
|
|
en orden, el último array sobrescribiendo los valores anteriores.
|
|
</para>
|
|
<para>
|
|
<function>array_replace_recursive</function> es recursiva: realizará la recursividad en los
|
|
arrays y aplicará el mismo proceso al valor interno.
|
|
</para>
|
|
<para>
|
|
Cuando el valor en el primer array es escalar, será reemplazado
|
|
por el valor del segundo array, que puede ser escalar o un array.
|
|
Cuando el valor del primer y el segundo array
|
|
son arrays, <function>array_replace_recursive</function> reemplazará
|
|
sus respectivos valores recursivamente.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array1</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El array cuyos elementos son reemplazados.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>...</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Optional. Arrays de los que se extraerán 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"), );
|
|
$reemplazos = array('cítricos' => array('piña'), 'bayas' => array('arándano'));
|
|
|
|
$cesta = array_replace_recursive($base, $reemplazos);
|
|
print_r($cesta);
|
|
|
|
$cesta = array_replace($base, $reemplazos);
|
|
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' );
|
|
$reemplazos = array('cítricos' => 'piña', 'bayas' => array('arándano'), 'otros' => array('litchis'));
|
|
$reemplazos2 = array('cítricos' => array('piña'), 'bayas' => array('arándano'), 'otros' => 'litchis');
|
|
|
|
$cesta = array_replace_recursive($base, $reemplazos, $reemplazos2);
|
|
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>
|
|
<member><function>array_merge_recursive</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
|
|
-->
|