PHP array each() FunctionLast Updated : 17 Mar 2025 The each( ) function is an inbuilt function of PHP. It is used to fetch the key and value of the current element and moves the internal pointer forward. This function was introduced in PHP 4.0. SyntaxParameter
ReturnsThe each() function returns the current key and value pair from array_name. Example 1Output:
Array
(
[1] => OS
[value] => OS
[0] => 0
[key] => 0
)
Example 2Output:
Array
(
[1] =>sachin
[value] =>sachin
[0] => 0
[key] => 0
)
Example 3Output:
Array
(
[1] => dell
[value] =>dell
[0] => 0
[key] => 0
)
Example 4Output:
Array
(
[1] =>bengaluru
[value] =>bengaluru
[0] =>karnataka
[key] =>karnataka
)
Next TopicPhp-array-end-function |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India