Array_walk
(PHP3 >= 3.0.0, PHP4)
Array_walk---Enables custom functions to handle each element of an array
Grammar: int&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP;" Array_walk (Array arr, string func);
Description:
Arr each element of the array and the function name Func, the element is passed to the first argument of the function func, and if the function func more than one parameter, a warning message can be suppressed to suppress the warning message by adding ' @ ' to the function, or @array_walk, or by using the Error_ Reporting。
Note: This function does arr each element of the array, so any change in the element will affect the array itself.
Note: PHP4.0. New transfer index (key) and user data (UserData) to function func. In PHP4, Array_walk () preset does not reset (reset) array, so you must call reset ()
Example:
<?php
$fruits = Array ("D" => "Lemon", "a" => "Orange", "B" => "banana", "C" => "Apple");
function Test_alter ($item 1) {
$item 1 = ' bogus ';
}
function Test_print ($item 2) {
echo "$item 2<br>\n";
}
Array_walk ($fruits, ' test_print ');
Reset ($fruits);
Array_walk ($fruits, ' test_alter ');
Reset ($fruits);
Array_walk ($fruits, ' test_print ');
?>
Reference: each () List ()