📜  php array_walk - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:06.535000             🧑  作者: Mango

代码示例2
PHP function array_walk(object|array &$array, callable $callback, mixed $arg) bool
------------------------------------------------------------------------------  
Apply a user function to every member of an array.
  
Parameters:
array|object--$array--The input array.
callable--$callback--Typically, funcname takes on two parameters. The array parameter's value being the first, and the key/index second.
If funcname needs to be working with the actual values of the array, specify the first parameter of funcname as a reference. Then, any changes made to those elements will be made in the original array itself.
Users may not change the array itself from the callback function. e.g. Add/delete elements, unset elements, etc. If the array that array_walk is applied to is changed, the behavior of this function is undefined, and unpredictable.
mixed--$arg--[optional] If the optional userdata parameter is supplied, it will be passed as the third parameter to the callback funcname.

Returns: true on success or false on failure.