PHP: list - Manual in Deutsh
PHP: list - Manual in French
PHP: list - Manual in Polish

You Are At PHP: list - Manual Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

list

(PHP 3, PHP 4, PHP 5)

list -- Assign variables as if they were an array

Description

void list ( mixed varname, mixed ... )

Like array(), this is not really a function, but a language construct. list() is used to assign a list of variables in one operation.

Note: list() only works on numerical arrays and assumes the numerical indices start at 0.

Example 1. list() examples

<?php

$info
= array('coffee', 'brown', 'caffeine');

// Listing all the variables
list($drink, $color, $power) = $info;
echo
"$drink is $color and $power makes it special.\n";

// Listing some of them
list($drink, , $power) = $info;
echo
"$drink has $power.\n";

// Or let's skip to only the third one
list( , , $power) = $info;
echo
"I need $power!\n";

?>

Example 2. An example use of list()

<table>
<tr>
  <th>Employee name</th>
  <th>Salary</th>
</tr>

<?php

$result
= mysql_query("SELECT id, name, salary FROM employees", $conn);
while (list(
$id, $name, $salary) = mysql_fetch_row($result)) {
    echo
" <tr>\n" .
          
"  <td><a href=\"info.php?id=$id\">$name</a></td>\n" .
          
"  <td>$salary</td>\n" .
          
" </tr>\n";
}

?>

</table>

Warning

list() assigns the values starting with the right-most parameter. If you are using plain variables, you don't have to worry about this. But if you are using arrays with indices you usually expect the order of the indices in the array the same you wrote in the list() from left to right; which it isn't. It's assigned in the reverse order.

Example 3. Using list() with array indices

<?php

$info
= array('coffee', 'brown', 'caffeine');

list(
$a[0], $a[1], $a[2]) = $info;

var_dump($a);

?>

Gives the following output (note the order of the elements compared in which order they were written in the list() syntax):

array(3) {
  [2]=>
  string(8) "caffeine"
  [1]=>
  string(5) "brown"
  [0]=>
  string(6) "coffee"
}

See also each(), array() and extract().

Jak ograniczyć jedzenie słodyczy Jak ograniczyć jedzenie słodyczy
6
www.finansowo.podejrzliwy.kalisz.pl
Prezenty
tanie holowanie Rzeszów

Another Useful functions:


zend-api.zend-rsrc-list-get-rsrc-type | zend-api.zend-register-list-destructors | zend-api.zend-register-list-destructors-ex | zend-api.zend-list-insert | zend-api.zend-list-find | zend-api.zend-list-delete | zend-api.zend-list-addref | zend-api.zend-fetch-list-dtor-id | zend-api.register-list-destructors | function.xmlwriter-write-dtd-attlist | function.xmlwriter-start-dtd-attlist | function.xmlwriter-end-dtd-attlist | function.xattr-list | function.win32-ps-list-procs | function.udm-cat-list | function.timezone-identifiers-list | function.timezone-abbreviations-list | function.swishresult-getmetalist | function.swish-getpropertylist | function.swish-getmetalist | function.ssh2-publickey-list | function.socket-listen | function.socket-create-listen | function.sdo-list-insert | function.sdo-das-setting-getlistindex | function.readline-list-history | function.rar-list | function.pspell-save-wordlist | function.printer-list | function.openal-listener-set | function.openal-listener-get | function.ob-list-handlers | function.notes-list-msgs | function.newt-listitem | function.newt-listitem-set | function.newt-listitem-get-data | function.newt-listbox | function.newt-listbox-set-width | function.newt-listbox-set-entry | function.newt-listbox-set-data | function.newt-listbox-set-current | function.newt-listbox-set-current-by-key | function.newt-listbox-select-item | function.newt-listbox-item-count | function.newt-listbox-insert-entry | function.newt-listbox-get-selection | function.newt-listbox-get-current | function.newt-listbox-delete-entry | function.newt-listbox-clear | function.newt-listbox-clear-selection | function.newt-listbox-append-entry | function.mysql-list-tables | function.mysql-list-processes | function.mysql-list-fields | function.mysql-list-dbs | function.msql-list-tables | function.msql-list-fields | function.msql-list-dbs | function.msession-listvar | function.msession-list | function.mcrypt-list-modes | function.mcrypt-list-algorithms | function.mcal-list-events | function.mcal-list-alarms | function.mb-list-mime-names | function.mb-list-encodings | function.mb-list-encodings-alias-names | function.list | function.ldap-list | function.ircg-list | function.imap-rfc822-parse-adrlist | function.imap-listsubscribed | function.imap-listscan | function.imap-listmailbox | function.imap-list | function.imagick-pushlist | function.imagick-poplist | function.imagick-newimagelist | function.imagick-getlistsize | function.imagick-getlistindex | function.imagick-getimagefromlist | function.id3-get-genre-list | function.icap-list-events | function.icap-list-alarms | function.hwapi-userlist | function.headers-list | function.ftp-rawlist | function.ftp-nlist | function.filter-list | function.fbsql-list-tables | function.fbsql-list-fields | function.fbsql-list-dbs | function.enchant-broker-list-dicts | function.dom-domnodelist-item | function.dblist | function.dba-list | function.aggregate-properties-by-list | function.aggregate-methods-by-list | faq.mailinglist |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.