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
Look at a piece of code first1 DOCTYPE HTML>2 HTMLLang= "en">3 Head>4 MetaCharSet= "UTF-8">5 title>Documenttitle>6 Head>7 Body>8 9 Script>Ten //an ordinary array One vararr=[3,5,2,6]; A //normal for loop
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
From: http://www.cnblogs.com/kakaku/articles/1312826.html
the tag is used to create a loop on the page to traverse objects such as arrays, collections, and maps. This tag is powerful and is often used on Struts application pages.1. cyclically
Prototypes are provided to us in order for us to extend more versatility.Today I learned to use JS simulation of the underlying code, the implementation of multidimensional traversal of the array. The idea is to add a method to the array prototype.1
In awk, arrays are random, and elements in the same array are not necessarily of the same type, and the following table can be numbers or characters.There are two ways to iterate through an array:1. Methods similar to C + +#--------------------------
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
Look at a piece of code first1 2 3 4 5 document 6 7 8 9 21 22 This code shows a bit of the difference between A for loop traversal array and a for-in loop through an array: The standard for-loop i is the number type, which
Since the ECMA provides a way to iterate through an array, foreach () can only traverse one-dimensional arrays and does not provide a way to iterate through a multidimensional array, so we implement a each () method ourselves to traverse the
Click to enter _ more _java thousand ask1. How to iterate through an arrayWhen we work with arrays, we often use a for loop or a foreach loop to iterate because all the elements in the array are of the same type and the size of the array is
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.