Welcome to the Linux community forum and interact with 2 million technical staff. PHP is a scripting language for WEB development. I think you have a deep understanding of it, here I will discuss PHP array traversal and hope to help you. Apache2.0 and PHP5.0 installation expert guide PHP installation and configuration mainstream Apache2PHP
Welcome to the Linux community forum and interact with 2 million technical staff> entering PHP is a scripting language for WEB development. I think you have a deep understanding of it, here I will discuss PHP array traversal and hope to help you. How to install and configure Apache 2.0 and PHP5.0
Welcome to the Linux community forum and interact with 2 million technicians>
PHP is a scripting language for WEB development. I think you have a deep understanding of it. Here I will discuss PHP array traversal and hope to help you.
How to install Apache 2.0 and PHP5.0
PHP installation and configuration
Introduction to mainstream Apache 2 PHP5 Installation and Use
Deep Learning about PHP configuration
PHP array loop operations
We all know the superiority of arrays. Now we will learn how to traverse the data in PHP arrays. The application of this array method is very common, and I believe you will have a good grasp. For example, if your website contains a large amount of website data and you want to display the portal website on a page, the data has been saved to an array variable $ url, so how to output the data one by one to a webpage? Do you still think of echo output one by one in the previous lesson? Don't forget that the data size is very large and the number of data changes frequently.
PHP array traversal Syntax:
Foreach (array_expressionas $ key => $ value) statement
In the second format, only the key value of the current unit is assigned to the variable $ key in each loop.
Example 1:
Note: When foreach starts to execute, the pointer inside the array automatically points to the first unit. This means that you do not need to call reset () before the foreach loop (). Note: foreach operates on a copy of the specified array, rather than the array itself. Therefore, even if each () is constructed, the original array pointer is not changed, and the value of the array unit is not affected. Note: foreach does not support "@" to prohibit error messages.