Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function list()


previous

Advertisements

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.

Paramters

ParameterDescription
var1Required. The first variable to assign a value to
var2Optional. The second variable to assign a value to
var3Optional. The third variable to assign a value to

Return Value

This does not return anything.

Example

Try out following example:

<?php
$my_array = array("mango","apple","banana");

list($a, $b, $c) = $my_array;
echo "I have several fruits, a $a, a $b and a $c.";
?> 

This will produce following result:

I have several fruits, a mango, a apple, a banana

previous Printer Friendly

Advertisements


  

Advertisements