Php array traversal foreach ($ arras & $ value) usage

Source: Internet
Author: User
Php array traversal foreach ($ arras & amp; $ value) usage
This article introduces how to use foreach loop to traverse arrays in php. For more information, see.

From php5, you can add & before $ value to modify the elements of the array. This method will assign values by reference instead of copying a value, which reduces the waste of space and is a good method.

Example:

     

This method is only available when the retrieved array can be referenced (for example, a variable ).

Example:

     

Http://bbs.it-home.org/shouce/php5/control-structures.foreach.html

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.