php each() function


  Translation results:

英 [i:tʃ] US [itʃ]

adj.Every; each; their own

pron. Each; their own

php each() functionsyntax

Function:Return the key name and key value of the current element, and move the internal pointer forward

Syntax: each(array)

Parameters:

##array Required. Specifies the array to use.
ParametersDescription

Description: Generate an array consisting of the key name and key value of the element pointed to by the current internal pointer of the array, and move the internal pointer forward . The returned array contains four elements: key 0, 1, key and value. Cells 0 and key contain the key names of the array cells, and 1 and value contain the data. If the internal pointer exceeds the range of the array, this function returns FALSE.

php each() functionexample

<?php
$a=array("php中文网","西门","讲师","灭绝师太","无忌哥哥");
print_r(each($a));
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

Array ( [1] => php中文网 [value] => php中文网 [0] => 0 [key] => 0 )


<?php
$a=array("无忌哥哥","灭绝师太","讲师","php中文网","西门");
print_r(each($a));
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

Array ( [1] => 无忌哥哥 [value] => 无忌哥哥 [0] => 0 [key] => 0 )

Popular Recommendations

Home

Videos

Q&A