note 34379 added to function.array-walk

From: Date: Fri, 25 Jul 2003 08:33:55 +0000
Subject: note 34379 added to function.array-walk
Groups: php.notes 
Request: Send a blank email to php-notes+get-52621@lists.php.net to get a copy of this message
You can make it go through multi-dimensional arrays! Just write the callback to do so. Such as: function test_alter (&$item1, $key, $prefix) { if(is_array($item1)) { array_walk ($item1, 'test_alter', 'fruit'); return; } $item1 = "$prefix: $item1"; } If an item of the array is itself an array, it will call array_walk() with the same callback on the sub-array. ALERT! This is not tested code, it is just to give an idea, it "should" be correct, but I may have missed details... ---- Manual Page -- http://www.php.net/manual/en/function.array-walk.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34379 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34379&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34379&report=yes

« previous php.notes (#52621) next »