php中array_walk()
和array_walk_recursive()
之间有什么区别?请提供示例。
答案 0 :(得分:0)
答案 1 :(得分:0)
我们可以将array_walk_recursive()用于多维数组。
array_walk() // Its useful for one-dimensional array.
array_walk_recursive() // Calling array_walk() function in recursively (i.e., function call inside the same function).
答案 2 :(得分:-1)
<?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");
?>
<强> ANSWER 强> 键a的值为红色 键b的值为绿色 键1的值为蓝色 键2的值为黄色
=============================================== =======================
<?php
function myfunction($value,$key)
{
echo "The key $key has the value $value<br>";
}
$a=array("a"=>"red","b"=>"green","c"=>"blue");
array_walk($a,"myfunction");
?>
<强> ANSWER 强> 键a的值为红色 键b的值为绿色 键c的值为蓝色