cvs: phpdoc-pt_BR /reference/array/functions array-pop.xml list.xml
| From: | Lucas Rocha | Date: | Fri, 06 Sep 2002 14:25:07 +0000 |
| Subject: | cvs: phpdoc-pt_BR /reference/array/functions array-pop.xml list.xml | ||
| Groups: | php.doc.pt-br | ||
| Request: | Send a blank email to doc-pt-br+get-149@lists.php.net to get a copy of this message | ||
lucasr Fri Sep 6 10:25:07 2002 EDT
Modified files:
/phpdoc-pt_BR/reference/array/functions array-pop.xml list.xml
Log:
Making this file up-to-date
Index: phpdoc-pt_BR/reference/array/functions/array-pop.xml
diff -u phpdoc-pt_BR/reference/array/functions/array-pop.xml:1.3
phpdoc-pt_BR/reference/array/functions/array-pop.xml:1.4
--- phpdoc-pt_BR/reference/array/functions/array-pop.xml:1.3 Thu Sep 5 17:51:52 2002
+++ phpdoc-pt_BR/reference/array/functions/array-pop.xml Fri Sep 6 10:25:07 2002
@@ -25,18 +25,19 @@
<title>Exemplo de <function>array_pop</function></title>
<programlisting role="php">
<![CDATA[
-$cesta = array ("laranja", "melancia", "morango");
+$cesta = array ("laranja", "banana", "melancia",
"morango");
$fruta = array_pop ($cesta);
]]>
</programlisting>
<para>
- Depois disso, <varname>$cesta</varname> terá 2 elementos:
+ Depois disso, <varname>$cesta</varname> terá 3 elementos:
<screen role="php">
<![CDATA[
Array
(
[0] => laranja
- [1] => melancia
+ [1] => banana
+ [2] => melancia
)
]]>
</screen>
Index: phpdoc-pt_BR/reference/array/functions/list.xml
diff -u phpdoc-pt_BR/reference/array/functions/list.xml:1.3
phpdoc-pt_BR/reference/array/functions/list.xml:1.4
--- phpdoc-pt_BR/reference/array/functions/list.xml:1.3 Sat Jul 20 00:54:15 2002
+++ phpdoc-pt_BR/reference/array/functions/list.xml Fri Sep 6 10:25:07 2002
@@ -1,40 +1,74 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- EN-Revision: 1.2 Maintainer: lucasr Status: ready -->
+<!-- EN-Revision: 1.6 Maintainer: lucasr Status: ready -->
<!-- splitted from ./pt_BR/functions/array.xml, last change in rev 1.1 -->
<!-- last change to 'list' in en/ tree in rev 1.2 -->
<refentry id="function.list">
<refnamediv>
<refname>list</refname>
<refpurpose>
- Cria variáveis como se fossem arrays
+ Cria variáveis como se fossem arrays
</refpurpose>
</refnamediv>
<refsect1>
- <title>Descrição</title>
+ <title>Descrição</title>
<methodsynopsis>
<type>void</type><methodname>list</methodname>
<methodparam
rep="repeat"><type>mixed</type><parameter>...</parameter></methodparam>
</methodsynopsis>
<para>
- Assim como <function>array</function>, não é exatamente uma
função,
- e sim uma estrutura da própria linguagem. <function>list</function>
é usada
- para criar uma lista de variáveis em apenas um operação.
+ Assim como <function>array</function>, não é exatamente uma função,
+ e sim uma construção da própria linguagem. <function>list</function> é usada
+ para criar uma lista de variáveis em apenas um operação.
+ </para>
+ <note>
+ <para>
+ <function>list</function> só funciona em arrays com índices numéricos e
+ assume que esses índices começam de 0 (zero).
+ </para>
+ </note>
+ <para>
<example>
<title>Exemplo de <function>list</function></title>
<programlisting role="php">
<![CDATA[
+<?php
+
+$info = array('Café', 'marrom', 'cafeína');
+
+// Listando todas as variáveis
+list($bebida, $cor, $substancia) = $info;
+print "$bebida is $cor e $substancia a faz especial.\n";
+
+// Listando apenas alguns deles
+list($bebida, , $substanciar) = $info;
+print "$bebida tem $substancia.\n";
+
+// Ou ignoramos os primeiros valores para conseguir apenas o último
+list( , , $substancia) = $info;
+print "I need $substancia!\n";
+
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ <example>
+ <title>Exemplo de <function>list</function></title>
+ <programlisting role="php">
+<![CDATA[
<table>
<tr>
- <th>Nome do empregado</th>
- <th>Salário</th>
+ <th>Lista de empregados</th>
+ <th>Salário</th>
</tr>
<?php
-$resultado = mysql_query ("SELECT id, nome, salario FROM empregados",$conn);
-while (list ($id, $nome, $salario) = mysql_fetch_row ($resultado)) {
+$result = mysql_query ("SELECT id, nome, salario FROM empregados", $conn);
+while (list ($id, $nome, $salario) = mysql_fetch_row ($result)) {
print (" <tr>\n".
- " <td><a
href=\"info.php3?id=$id\">$nome</a></td>\n".
+ " <td><a
href=\"info.php?id=$id\">$nome</a></td>\n".
" <td>$salario</td>\n".
" </tr>\n");
}
@@ -63,7 +97,7 @@
<![CDATA[
<?php
-$info = array('café', 'marrom', 'cafeína');
+$info = array('café', 'marrom', 'cafeína');
list($a[0], $a[1], $a[2]) = $info;
@@ -71,21 +105,22 @@
]]>
</programlisting>
</example>
- O retorno desse script é o seguinte (note a ordem dos elementos em
- comparação com o array original):
+ O retorno desse script é o seguinte (note a ordem dos elementos em
+ comparação com o array original):
<screen>
array(3) {
[2]=>
- string(8) "cafeína"
+ string(8) "cafeína"
[1]=>
string(5) "marrom"
[0]=>
- string(6) "café"
+ string(6) "café"
}
</screen>
</para>
<para>
- Veja também <function>each</function> e
<function>array</function>.
+ Veja também <function>each</function>, <function>array</function>
+ e <function>extract</function>.
</para>
</refsect1>
</refentry>