PHP Calling Methods using Array_Walk
May 14, 2010 · 1 minute readCategory: php
This is post is now quite old and the the information it contains may be out of date or innacurate.
If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub
However, the standard documentation doesn’t make it clear if you can use array_walk on an array and use a class method as the callback rather than a global function. You can and here is how to do it:
$object = new MyClass;
$array = array(/* some array */);
array_walk($array, array($object, 'methodName'));