• PHP Video Tutorials

PHP - Function list()



Syntax

list ( $var1, $var2, $var3.. )

Definition and Usage

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

Parameters

Sr.No Parameter & Description
1

var1(Required)

The first variable to assign a value to

2

var2(Optional)

The second variable to assign a value to

3

var3(Optional)

The third variable to assign a value to

Return Value

This does not return anything.

Example

Try out following example −

<?php
   $fruit = array("mango","apple","banana");
   
   list($a, $b, $c) = $fruit;
   echo "I have several fruits, a $a, a $b, and a $c.";
?> 

This will produce the following result −

I have several fruits, a mango, a apple, and a banana
php_function_reference.htm
Advertisements