Arguments of array_walk_recursive(...)

I can’t understand how many arguments we can pass to array_walk_recursive(…) function.
The manual at:
manual entry for array_walk_recursive shows:
array_walk_recursive($fruits, ‘test_print’);
which has 2 arguments, whereas:
the program at: array_walk_recursive_link_in the sitepoint
shows 3 arguments:
array_walk_recursive($Color, ‘array_change_value_case’, CASE_LOWER);

The manual also provides one example like:
array_walk_recursive($fruits, ‘test_print’, ’ … Bio’);

What does the … mean ?


The following is the prototype definition of the function call -

array_walk_recursive(array|object &$array, callable $callback, mixed $arg = null): bool

There are three input parameters -

  1. The input array or object to operate on.
  2. The user defined call-back function that will be applied to each element of data.
  3. An optional (default value of null) user argument that will be passed through to the call-back function as its 3rd input parameter. This allows you to supply a call-time parameter through to the call-back function, without breaking program scope.

That’s just a literal string value with an obvious and distinguishable appearance, so that you can tell in the output what it contributed to the result - generates
“a beinhaltet Apfel … Bio

1 Like

Thanks for your response. What the words ‘callable’ and ‘mixed’ mean in the syntax of array_walk_recursive? Are they part of php keywords?


“Callable” means that the variable contains the name of a function that can be called. “Mixed” means that it is any type of variable. Because that optional third parameter type depends on the user-defined function provided in parameter 2, PHP cannot know what type of variable it might be.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.