PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

USING THE list() FUNCTION ON PHP ARRAYS

The list() function allows you to retrieve several values at once from an array. The list() function copies values from the array into variables you specify.

Suppose you have this array:

$colors=array('blue', 'red', 'green');

Say you want to list the first two values of this array, you do:

list($firstValue, $secondValue) = $colors;

The list function creates two variables named $firstValue and $secondValue and stores the first and second values of the array in them consecutively.

echo $firstValue; // outputs blue

echo $secondValue; // outputs red

The above feature is equivalent to:

$firstValue = $colors[0];
$secondValue = $colors[1];

echo $firstValue; // outputs blue
echo $secondValue; // outputs red

See also:

What Are Arrays?
How To Create Arrays
How To View Arrays
How To Modify Arrays
Array arsort() Function
Array asort() Function
Array rsort() Function
Array sort() Function
Array ksort() Function
Array krsort() Function
Array Echo
Manual Array Iteration
Array count() & sizeof() Function




Home | Privacy Policy | Terms Of Use | Contact Us