Is it possible to use PHP array_walk with an anonymous function (before PHP 5.3)? or some workaround..
I’m using array_walk inside a public class method and I don’t want to define a PHP function.. I want to do something like:
array_walk($array, function($value) {...});
If that’s not possible is it possible to use a class method instead of a function?
Yes, you can pass an array as second parameter, containing the object and the method name as string:
prints
The signature of the
array_walk()(can be found in the documentation), defines the second argument as callback, for which the following description can be found: