array_walk函数有以下参数:
回调函数的参数如下:
示例:
$array = ['apple', 'banana', 'cherry'];
function myfunction($value, $key, $userdata) {
echo "$key: $value - $userdata\n";
}
array_walk($array, 'myfunction', 'fruit');
输出结果为:
0: apple - fruit
1: banana - fruit
2: cherry - fruit