Analysis of list () function usage examples in PHP

Source: Internet
Author: User
This article mainly introduces the usage of the list () function in PHP, and analyzes the functions, parameter definitions, usage skills, and related precautions of the list () function in combination with the instance form, for more information about the list () function in PHP, see the example in this article. 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 can only be an array of numeric indexes, and it is assumed that the numeric index starts from 0.

List () function definitionAs 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.

Sample codeAs 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.