note 9614 rejected and deleted from list by jmcastagnetto

From: Date: Wed, 15 Nov 2000 21:35:52 +0000
Subject: note 9614 rejected and deleted from list by jmcastagnetto
Groups: php.notes 
Request: Send a blank email to php-notes+get-7727@lists.php.net to get a copy of this message
list (unknown) list -- Assign variables as if they were an array Description void list(...); Like array(), this is not really a function, but a language construct. list() is used to assign a list of variables in one operation. Example 1. List() example <table> <tr> <th>Employee name</th> <th>Salary</th> </tr> &lt;?php $result = mysql ($conn, "SELECT id, name, salary FROM employees"); while (list ($id, $name, $salary) = mysql_fetch_row ($result)) { print (" <tr>n". " <td><a href="info.php3?id=$id">$name</a></td>n". " <td>$salary</td>n". " </tr>n"); } ?> </table> See also each() and array(). User Contributed Notes: list siggma@xs4all.be 08-Oct-1999 09:09 At first I thought that list(...) creates an array of references, so that <pre> $a='x'; $b='y'; $c='z'; $d=list($a,$b,$c); $d[1]='OK'; print $b; </pre> would give 'OK', the new value of $b put there through the reference in $d[1]; But no, list(...) is a function that requires to be assigned an array to... gs@e-nova.com.sg 18-Feb-2000 02:32 Suppose a list of three items is returned and you are only interested in items one and three, you can skip assigning item two by list($one, , $three) = some_function(); moosh@phpfrance.com 05-Aug-2000 01:47 list($a,$b,$c)=$myArray $myArray must be a scalar array and not an associative array. moosh@phpFrance.com 28-Aug-2000 04:44 list -- Transforme une liste de variables en tableau. --------------------------------------------- Les exemples montrent toujours qu'on fourni

« previous php.notes (#7727) next »