How to use list in PHP

In this article, I will explain how the list() function can be used in PHP.
  • 1767

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.




  • val1 val1 is required parameter. the first variable assign to val1.
  • val2 val2 is optional parameter. the second variable assign to val2 .


The following example show to how the list() function can be used in PHP.



<h3 style="color: blueviolet;">list() function example in PHP</h3>


    $array_demo = array("Welcome","to","C-sharpcorner");

    list($a, $b, $c) = $array_demo;

    echo " $a $b $c..";







You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.