note 63593 added to function.array-map

From: Date: Fri, 24 Mar 2006 19:00:57 +0000
Subject: note 63593 added to function.array-map
Groups: php.notes 
Request: Send a blank email to php-notes+get-106540@lists.php.net to get a copy of this message
I could be wrong, but IMHO the best way to perform array_map recursively AND preserve keys would be this: <?php # Apply a callback to an array and preserve keys, even if that array is multidimensional function x_array_map($callback, $array) { foreach($array as $k => $v) if(is_array($v)) $array[$k] = x_array_map($callback, $v); else $array[$k] = call_user_func($callback, $v); return $array; } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 69.180.200.126 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.array-map.php Edit -- http://master.php.net/note/edit/63593 Del: integrated -- http://master.php.net/note/delete/63593/integrated Del: useless -- http://master.php.net/note/delete/63593/useless Del: bad code -- http://master.php.net/note/delete/63593/bad+code Del: spam -- http://master.php.net/note/delete/63593/spam Del: non-english -- http://master.php.net/note/delete/63593/non-english Del: in docs -- http://master.php.net/note/delete/63593/in+docs Del: other reasons-- http://master.php.net/note/delete/63593 Reject -- http://master.php.net/note/reject/63593 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#106540) next »