PHP Array list() Function

What is list() Function?


The "list()" function assigns variables as if they were in an array.



In the above syntax "var1" is the first variable to be assigned and can have any number of variables.

Example :

list($a,$b,$c)= $myarray;
echo "I have several fruits $a, $b, $c";
Result :

I have several fruits Grapes, Apple, Cherry

In the above example the variables "$a,$b,$c" is assigned the values of the array "$myarray".

PHP Topics

Ask Questions

Ask Question