What does the array p[in PHP mean?

Source: Internet
Author: User
What does the array p[in PHP mean?

$g = Array ();

foreach ($re as $key = $val)
{
$g [] = new Class_a ($val);
}

P[] represents the current array pointer?


Reply to discussion (solution)

The manual has:
New/modified with square brackets syntax
You can change an existing array by explicitly setting the value.

This is done by assigning a value to the array by specifying the key name within the square brackets. You can also omit the key name, in which case a pair of empty brackets ("[]") are added to the variable name. $arr [key] = value;
$arr [] = value;
Key can be an integer or string
Value can be any value.


$g [] is assigned to the array $g, and in your case the index starts at 0.

$g [] is an empty array.

Thanks to the 2-bit version and zy205817,


You can omit the key name, in which case the variable name is given a pair of empty brackets ("[]"). $arr [key] = value;
$arr [] = value;

Mi understand.

  • Related Article

    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: info-contact@alibabacloud.com 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.