note 43064 added to function.array-walk

From: Date: Tue, 08 Jun 2004 18:26:32 +0000
Subject: note 43064 added to function.array-walk
Groups: php.notes 
Request: Send a blank email to php-notes+get-70696@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.array-walk.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43064 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43064&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43064&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70696) next »