mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
73dc1b8c2e
commit
f190f26f8f
1 changed files with 32 additions and 3 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue