How to use list in PHP
In this article, I will explain how the list() function can be used in PHP.
list() function in PHP
-
The list() function is used to assign values to a list of variables in one operation.
-
The list() function only works on numerical arrays.
-
The list() function can be hold multiple values.
Syntax
Parameter
- val1 val1 is required parameter. the first variable assign to val1.
- val2 val2 is optional parameter. the second variable assign to val2 .
Example
The following example show to how the list() function can be used in PHP.
<html>
<body>
<h3 style="color: blueviolet;">list() function example in PHP</h3>
<?php
$array_demo = array("Welcome","to","C-sharpcorner");
list($a, $b, $c) = $array_demo;
echo " $a $b $c..";
?>
</body>
</html>
|
Output

You may also want to read these related articles here
Got a programming related question? You may want to post your question here