Discover php iterate through array, include the articles, news, trends, analysis and practical advice about php iterate through array on alibabacloud.com
Reference URL: http://www.jb51.net/article/29949.htmThe most efficient of these three methods is the use of a foreach statement to iterate over an array. The foreach structure has been introduced since PHP4, which is a statement designed
There are many functions in PHP that can be used to iterate over an array, such as: For statement, list, each, foreach, four functions, which is also a few of the main functions of traversing the array in PHP, let me introduce to you.
foreach
. While traversalIn each loop of the while () statement, each () statement assigns the key of the current array element to the first argument variable $key of the list () function. and assigns the value in the current array element to the second
Learn PHP's array summary "experience", PHP array Summary
PHP has a lot of functions for arrays, which makes it easy to manipulate arrays.
Defined:
The array contains two items per entity: Key and value, which can be obtained by querying the key.
This article mainly introduces the 3 methods of the PHP loop traversal array list (), each () and while summary, focusing on the mixed use of the 3 methods of the explanation.
①each () function
each () function needs to pass an array as an argument,
The foreach syntax structure provides an easy way to iterate through an array. foreach can only be applied to arrays and objects, if you try to apply a variable to another data type, or an uninitialized variable will emit an error message. There are
The most manipulated data in PHP is the array, which has the characteristics of high efficiency, fast speed and convenient storage.There are three common ways to iterate through an array in PHP:1, for loop, use the most flexible, flexible to suspect
The most manipulated data in PHP is the array, which has the characteristics of high efficiency, fast speed and convenient storage.There are three common ways to iterate through an array in PHP:1, for loop, use the most flexible, flexible to suspect
PHP arraysFeatures: can store any type of data, can be discontinuous, can be indexed or can be associatedWhat is an index?is a common array of styles, index from the beginning, 0,1,2,3, the definition of the array is directly inside the value, only
For Web programming, the most important thing is to access and read and write data. There may be many ways to store them, such as strings, arrays, files, and so on. arrays, which can be said to be a more important way of data application in PHP. PHP
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.