How to use each in php
This article mainly explains "how to use each in php". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor learn how to use each in php.
In PHP, the each () function returns the key name and key value of the current element and moves the internal pointer forward; this function can generate an array of element key names and key values pointed to by the current internal pointer of the array. If the internal pointer goes beyond the range of the array, the result returned by the function is false and the syntax is "each (array)".
This article operating environment: Windows10 system, PHP5.6 version, Dell G3 computer
What is the use of each in php
The each () function returns the key name and key value of the current element and moves the internal pointer forward.
The key name and key value of the element are returned to the array with four elements. Two elements (1 and Value) contain key values, and two elements (0 and Key) contain key names.
Each (array)
Array is required. Specifies the array to be used.
Description
The each () function generates an array of key names and key values of the elements that the array's current internal pointer points to, and moves the internal pointer forward.
There are four elements in the returned array: the keys are 0Magne1, rekey and value. Cell 0 and key contain the key name of the array unit, and 1 and value contain data.
This function returns FALSE if the internal pointer goes beyond the range of the array.
Examples are as follows:
Output result:
Tip: the each () function is deprecated in PHP 7.2.0.
At this point, I believe you have a deeper understanding of "how to use each in php". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!