1. array_walkboolarray_walk (array & amp; $ array, callable $ funcname [, mixed $ userdataNULL]) 1. function to apply user functions to each member in the array. description: user-defined functions & nbsp; funcname & n 1, array_walk
bool array_walk ( array &$array , callable $funcname [, mixed $userdata = NULL ] )
1. Functions
Apply user functions to each member in the array
2. description
Set user-defined functions?funcname
? Apply?array
? Each cell in the array.
Array_walk ()? Not affected?array
? The impact of internal array pointers.Array_walk ()? It will traverse the entire array regardless of the pointer position.
3. parameters
array——
Input array.
funcname——
In typical cases?funcname
? Two parameters are accepted.array
? The value of the parameter is the first and the key name is the second.
Note::
If?funcname
? If you want to directly act on the values in the array?funcname
? The first parameter is specified as reference. In this way, any change to these units will also change the original array itself.
Only?array
? Can be changed. you should not change the structure of the array in the callback function. For example, adding/deleting a unit or unset a unit. If?Array_walk ()? If the array is changed, the behavior of this function is undefined and unpredictable.
userdata——
If an optional parameter is provided?userdata
Will be passed to callback as the third parameter?funcname
.
4. return value
?TRUE
, Or return when a failure occurs?FALSE
.
5. Error/exception
If?funcname
? If the function requires more parameters than the given one, then?Array_walk ()? Call?funcname
? ? E_WARNING? Level error. These warnings can be passed in?Array_walk ()? Is the PHP error operator added before the call? @? To suppress, or use? Error_reporting ().
6. related functions
Array_pai_recursive --?? Recursively apply user functions to each member in the array
II. array_values
?array array_values ( array $input )
1. Functions
Returns all values in the array.
2. description
Array_values ()? ?input
? All values in the array and create a digital index for them.
3. parameters
input——
Array
4. return value
Returns an index array containing all values.
5. related functions
Array_keys-returns all the key names in the array.
array array_keys ( array $input [, mixed $search_value = NULL [, bool $strict = false ]] )
Parameter description:
input ——?
An array containing the keys to be returned.
search_value ——?
If this parameter is specified, only keys containing these values are returned.
strict ——?
Determine whether to use strict comparison (=) during search ).
III. example
1. array_walk Sample code
"; print_r($form);?>
Output result:
a:phpb:jsc:yiiArray( [a] => php [b] => js [c] => yii)
2. array_values usage example
When some Zend extension cache components are used, the array_walk function may conflict with the array_walk function, and the array_walk function cannot be used normally. to implement the above functions, the array_values function must be used:
Output result:
Array( [a] => php [b] => js [c] => yii)