1. Arrays in PHP Rather than understanding arrays in PHP as "arrays" in our narrow sense, I think we might as well divide this array into two, and one is our conventional Array, one is our Dictionary. 2. Create an array If the array does not exist, storing values in the array will create the array.
Foreach traverses the array very easily, but it has a disadvantage, that is, it does not directly operate the original array, but makes a copy of the original array before traversing, which causes time and space problems. of waste. Then there is a simple method, which is for.
Although this is simple, it also has disadvantages, that is, it can only traverse the index array, and there is no way to traverse the dictionary. So, the iterator function was proposed in PHP. The most commonly used one is the each() function. Let’s look at a simple example:
To explain, the each() function is used to traverse array elements, similar to our iterator in the conventional sense. And the biggest advantage of using the iterative function is that it does not produce a copy of the original array like the foreach language structure, which is very useful when dealing with large arrays.
http://www.bkjia.com/PHPjc/321375.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321375.htmlTechArticle1. Arrays in PHP Rather than understanding arrays in PHP as "arrays" in our narrow sense, I think You might as well divide this array into two, one is our regular array, the other is our...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn