mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 15:12:23 +01:00
160 lines
4.1 KiB
XML
160 lines
4.1 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- EN-Revision: 627fb8f8675566dfd9c3977e3ad2d9fc7b3b3876 Maintainer: ae Status: ready --><!-- CREDITS: lucasr,narigone,felipe,ae,lhsazevedo -->
|
|
<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 rep="repeat"><type>mixed</type><parameter>values</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.
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
Se a função <function>array_push</function> for usada para adicionar um elemento ao
|
|
array, é melhor usar <literal>$array[] = </literal> porque desta forma
|
|
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 era diferente do funcionamento de
|
|
<literal>$var[]</literal> onde um novo array era criado, antes do PHP 7.1.0.
|
|
</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>values</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Os valores a serem colocados no final do <parameter>array</parameter>.
|
|
</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="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>7.3.0</entry>
|
|
<entry>
|
|
Essa função agora pode ser chamada com apenas um parâmetro. Anteriormente, pelo
|
|
menos dois parâmetros eram necessários.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</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:"~/.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
|
|
-->
|