The list () function in PHP is used to assign a value to a set of variables in one operation.

note:The array variable here can only be a numerically indexed array.It is also assumed that the numeric index starts at 0.

list () function definitionThe following:

list (var1, var2 ...)

Parameter Description:

var1 is required. The first variable to be assigned.

var2, ... Optional. More variables that need to be assigned.

Sample codeThe following:

 //$arr=array ("name" =>"tom", "pwd" =>"123456");//Error! The index must be numeric!
 //$arr=array ("1" =>"tom", "2" =>"123456");//Error! The numeric index must start at 0!
 $arr=array ("tom", "123456");
 list ($name, $pwd)=$arr;
 echo "welcome". $name. "! remember your password:". $pwd;
  • Previous jQuery custom scroll bar complete example
  • Next How to solve android Toast duplicate display