what is list in php?

24 Views

what is list in php?

List 

List is a language construct and is similar to an array. It is used to assign a list of variables in one operation. If you are using PHP 5, then the list values start from a right parameter, and if you are using PHP 7, then the list starts with left parameter.

 
 <?php

$info = array('red', 'sign', 'danger');

// Listing all the variables
list($color, $symbol, $fear) = $info;

echo "$color is $symbol of $fear”;

?>

 

Tags:-
PHP