PHP array_walk_recursive () function
Examples
Each element in the array application user-defined function:
<?php
function myfunction($value,$key)
{
echo "The key $key has the value $value<br>";
}
$a1=array("a"=>"red","b"=>"green");
$a2=array($a1,"1"=>"blue","2"=>"yellow");
array_walk_recursive($a2,"myfunction");
?>
function myfunction($value,$key)
{
echo "The key $key has the value $value<br>";
}
$a1=array("a"=>"red","b"=>"green");
$a2=array($a1,"1"=>"blue","2"=>"yellow");
array_walk_recursive($a2,"myfunction");
?>
Running instance »
Definition and Usage
array_walk_recursive () function for each element in the array apply user-defined functions. In the function, the array of key names and values are parameters. This function array_walk () different functions that can operate deeper array (an array containing other arrays).
grammar
array_walk_recursive( array,myfunction,parameter... )
参数 | 描述 |
---|---|
array | 必需。规定数组。 |
myfunction | 必需。用户自定义函数的名称。 |
parameter,... | 可选。规定用户自定义函数的参数,您可以为函数设置一个或多个参数。 |
technical details
return value: | If successful it returns TRUE, otherwise returns FALSE. |
---|---|
PHP version: | 5+ |
Complete PHP Array Reference