w3resource logo


PHP each function

PHP : each() function

rating has average rating 6 out of 10. Total 1 users rated.

<<PreviousNext>>

Description

The each() function is used to fetch the key and value of the current element. The function also moves the internal array pointer forward.

Version

(PHP 4 and above)

Syntax

each(array_name)

Parameter

Name Description Required /
Optional
Type
array_name The input array. Required Array

Return value

The current key and value pair from array_name.

Value Type : Array

Pictorial Presentation :

php array each() function

Example :

<?php
$subject= array('Language','English','Math','Science');
$result = each($subject);
print_r($result);
?>

Output :

Array ( [1] => Language [value] => Language [0] => 0 [key] => 0 )

View the example in the browser

See also

PHP Function Reference

<<PreviousNext>>

Rate this tutorial


Your Rating: not set

Share this tutorial

RSS Feed