mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-23 22:52:12 +01:00
187 lines
5.2 KiB
XML
187 lines
5.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: a51ec6735093d3f71d8b2139967851a7b6df3d65 Maintainer: marcosmarcolin Status: ready --><!-- CREDITS: marcosmarcolin -->
|
|
<refentry xml:id="function.array-replace-recursive" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_replace_recursive</refname>
|
|
<refpurpose>Substitui elementos de arrays passado no primeiro array recursivamente</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_replace_recursive</methodname>
|
|
<methodparam><type>array</type><parameter>array</parameter></methodparam>
|
|
<methodparam rep="repeat"><type>array</type><parameter>replacements</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_replace_recursive</function> substitui os valores de
|
|
<parameter>array</parameter> pelos mesmos valores de todos os arrays
|
|
seguintes. Se uma key do primeiro array existir no segundo array, seu valor
|
|
será substituído pelo valor do segundo array. Se a key existir no segundo array,
|
|
e não no primeiro, ela será criada no primeiro array.
|
|
Se uma key existir apenas no primeiro array, ela será deixada como está.
|
|
Se vários arrays forem passados para substituição, eles serão processados em ordem,
|
|
o array posterior sobrescrevendo os valores anteriores.
|
|
</para>
|
|
<para>
|
|
<function>array_replace_recursive</function> é recursivo: ele será recursivo
|
|
em arrays e aplicará o mesmo processo ao valor interno.
|
|
</para>
|
|
<para>
|
|
Quando o valor do primeiro array for escalar, ele será substituído
|
|
pelo valor do segundo array, seja ele escalar ou array.
|
|
Quando o valor no primeiro array e no segundo array são
|
|
ambos arrays, <function>array_replace_recursive</function> substituirá
|
|
seus respectivos valores recursivamente.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O array no qual os elementos são substituídos.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>replacements</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Arrays dos quais os elementos serão extraídos.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns an <type>array</type>.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemplo de <function>array_replace_recursive</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$base = array('frutas_citricas' => array( "laranja") , 'frutas_vermelhas' => array("amora", "framboesa"), );
|
|
$substituicoes = array('frutas_citricas' => array('abacaxi'), 'frutas_vermelhas' => array('mirtilo'));
|
|
|
|
$cesta = array_replace_recursive($base, $substituicoes);
|
|
print_r($cesta);
|
|
|
|
$cesta = array_replace($base, $substituicoes);
|
|
print_r($cesta);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[frutas_citricas] => Array
|
|
(
|
|
[0] => abacaxi
|
|
)
|
|
|
|
[frutas_vermelhas] => Array
|
|
(
|
|
[0] => mirtilo
|
|
[1] => framboesa
|
|
)
|
|
|
|
)
|
|
Array
|
|
(
|
|
[frutas_citricas] => Array
|
|
(
|
|
[0] => abacaxi
|
|
)
|
|
|
|
[frutas_vermelhas] => Array
|
|
(
|
|
[0] => mirtilo
|
|
)
|
|
|
|
)
|
|
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<example>
|
|
<title><function>array_replace_recursive</function> e recursive behavior</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$base = array('frutas_citricas' => array("laranja") , 'frutas_vermelhas' => array("amora", "framboesa"), 'outras' => 'banana' );
|
|
$substituicoes = array('frutas_citricas' => 'abacaxi', 'frutas_vermelhas' => array('mirtilo'), 'outras' => array('lichia'));
|
|
$substituicoes2 = array('frutas_citricas' => array('abacaxi'), 'frutas_vermelhas' => array('mirtilo'), 'outras' => 'lichia');
|
|
|
|
$cesta = array_replace_recursive($base, $substituicoes, $substituicoes2);
|
|
print_r($cesta);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[frutas_citricas] => Array
|
|
(
|
|
[0] => abacaxi
|
|
)
|
|
|
|
[frutas_vermelhas] => Array
|
|
(
|
|
[0] => mirtilo
|
|
[1] => framboesa
|
|
)
|
|
|
|
[outras] => lichia
|
|
)
|
|
]]>
|
|
</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
|
|
-->
|