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