19-How to using each function in PHP | Array | PHP Developer

Publié le: 13 février 2025
sur la chaîne: Professional Skill 2023
27
3

PHP each() Function
The each() function is an inbuilt function in PHP and is used to get the current element key-value pair of the given array to which the internal pointer is currently pointing. After returning the key and value of the current element the internal pointer is incremented by one in the array.

Definition and Usage
The each() function returns the current element key and value, and moves the internal pointer forward.

Note: The each() function is deprecated in PHP 7.2.
This element key and value 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.

Related methods:
1-current() - returns the value of the current element in an array
2-end() - moves the internal pointer to, and outputs, the last element in the array
3-next() - moves the internal pointer to, and outputs, the next element in the array
4-prev() - moves the internal pointer to, and outputs, the previous element in the array
5-reset() - moves the internal pointer to the first element of the array

Syntax
each(array)
Parameter Values
Parameter Description
array Required. Specifies the array to use


Sur cette page du site, vous pouvez voir la vidéo en ligne 19-How to using each function in PHP | Array | PHP Developer durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Professional Skill 2023 13 février 2025, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 27 fois et il a aimé 3 téléspectateurs. Bon visionnage!