: This article mainly introduces an example of list function usage in PHP. For more information about PHP tutorials, see. This example describes the usage of the list () function in PHP. We will share this with you for your reference. The details are as follows:
The list () function in PHP is used to assign values to a group of variables in an operation.
Note: The array variable here can only be an array of numeric indexes, and it is assumed that the numeric index starts from 0.
The list () function is defined as follows:
List (var1, var2 ...)
Parameter description:
Var1 is required. The first variable to be assigned a value.
Var2,... optional. More variables to be assigned values.
The sample code is as follows:
<? Php // $ arr = array ('name' => 'Tom ', 'pwd' => '123'); // error! The index must be a Digital Index! // $ Arr = array ('1' => 'Tom ', '2' => '123'); // error! The number index must start from 0! $ Arr = array ('Tom ', '123'); list ($ name, $ pwd) = $ arr; echo "Welcome". $ name ."! Remember your password: ". $ pwd;?>
I hope this article will help you with PHP programming.
The preceding section describes the usage of the list function in PHP, including the following content. I hope to help anyone who is interested in the PHP Tutorial.