list: Added more examples, which demonstrate ,,, syntax

See also extract()


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@75535 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2002-03-28 00:26:19 +00:00
parent 73dc1b8c2e
commit f190f26f8f

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.169 $ -->
<!-- $Revision: 1.170 $ -->
<reference id="ref.array">
<title>Array Functions</title>
<titleabbrev>Arrays</titleabbrev>
@ -3127,8 +3127,36 @@ d = lemon
Like <function>array</function>, this is not really a function,
but a language construct. <function>list</function> is used to
assign a list of variables in one operation.
</para>
<para>
<example>
<title><function>list</function> example</title>
<title><function>list</function> examples</title>
<programlisting role="php">
<![CDATA[
<?php
$info = array('coffee', 'brown', 'caffeine');
// Listing all the variables
list($drink, $color, $power) = $info;
print "$drink is $color and $power makes it special.\n";
// Listing some of them
list($drink, , $power) = $info;
print "$drink has $power.\n";
// Or let's skip to only the third one
list( , , $power) = $info;
print "I need $power!\n";
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>An example use of <function>list</function></title>
<programlisting role="php">
<![CDATA[
<table>
@ -3155,7 +3183,8 @@ while (list ($id, $name, $salary) = mysql_fetch_row ($result)) {
</example>
</para>
<para>
See also <function>each</function> and <function>array</function>.
See also <function>each</function>, <function>array</function>
and <function>extract</function>.
</para>
</refsect1>
</refentry>