mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 07:02:09 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/pt_BR/trunk@249643 c90b9560-bf6c-de11-be94-00142212c4b1
135 lines
3.5 KiB
XML
135 lines
3.5 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- EN-Revision: 1.16 Maintainer: felipe Status: ready --><!-- CREDITS: lucasr, narigone -->
|
|
<refentry xml:id="function.array-push" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_push</refname>
|
|
<refpurpose>Adiciona um ou mais elementos no final de um array</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>array_push</methodname>
|
|
<methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
|
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_push</function> trata <parameter>array</parameter> como uma
|
|
pilha, e adiciona as variáveis passadas como argumentos no final de
|
|
<parameter>array</parameter>. O tamanho do <parameter>array</parameter>
|
|
aumenta de acordo com o número de variáveis adicionadas. Tem o mesmo efeito de:
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$array[] = $var;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
repetido para cada argumento <parameter>var</parameter>.
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
Se você usar <function>array_push</function> para adicionar um elemento na
|
|
array, é melhor usar <literal>$array[] = </literal> porque deste jeito
|
|
não há uma chamada a uma função.
|
|
</simpara>
|
|
</note>
|
|
<note>
|
|
<simpara>
|
|
<function>array_push</function> irá emitir um aviso se o primeiro argumento
|
|
não for um array. isto é diferente do funcionamento de
|
|
<literal>$var[]</literal> aonde uma nova matriz é criada.
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O array de entrada.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>var</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O valor a ser adicionado.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retorna o novo número de elementos do array.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemplo de <function>array_push</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$cesta = array("laranja", "morango");
|
|
array_push($cesta, "melancia", "batata");
|
|
print_r($cesta);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[0] => laranja
|
|
[1] => morango
|
|
[2] => melancia
|
|
[3] => batata
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>array_pop</function></member>
|
|
<member><function>array_shift</function></member>
|
|
<member><function>array_unshift</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:"../../../../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
|
|
-->
|