note 43064 deleted from function.array-walk by aidan

From: Date: Sun, 11 Jul 2004 02:07:00 +0000
Subject: note 43064 deleted from function.array-walk by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73021@lists.php.net to get a copy of this message
Note Submitter: marx@program.ru ---- An additive improvement to Dandimaar's recursive function is: function array_walk_recur(&$array, $function, $data=NULL) { foreach ($array as $key => $value) { if (is_array($value)) array_walk_recur($value, $function, $data); else call_user_func_array($function, array($value, $key, $data)); $array[$key] = $value; } } which allows things like this to be done: array_walk_recur($array, array($this, 'myMethod'), 'my data'); I think that recursion can't be used with the built-in array_walk should be documented, since no one is committed to fixing bugs that pseudo-functional programmers of PHP use.

« previous php.notes (#73021) next »