- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
each() function in PHP
The each() function returns the current key and value pair from an array.
Note − This function has been deprecated as of PHP 7.2.0 and should be avoided.
Syntax
each(arr)
Parameters
arr − The specified array
Return
The each() function returns the current element key and value. This is returned in an array with four elements −
Two elements (1 and value) for the element value, and
Two elements (0 and key) for the element key.
Example
The following is an example −
<?php $prod = array("Electronics", "Footwear", "Toys"); print_r (each($prod)); ?>
Output
Array ( [1] => Electronics [value] => Electronics [0] => 0 [key] => 0 )
Advertisements