note 10591 added to array_walk

From: Date: Thu, 11 Jan 2001 20:07:01 +0000
Subject: note 10591 added to array_walk
Groups: php.notes 
Request: Send a blank email to php-notes+get-9663@lists.php.net to get a copy of this message
Here's a similar function: Function Array_Walk2($Array, $Function) { // This function will apply a function to all an array's values. // The values will be quoted in the function call if $Use_Quotes is true. // Only deal with array's and real functions. If (!Is_Array($Array) OR !Function_Exists($Function)) Return $Array; // Force pointer to be at the first element of the array. Reset($Array); // Iterate through all values. While(List($Key, $Value) = Each($Array)) { // If the element is an array, do that too. If (Is_Array($Array[$Key])) { // It's an array, let's get recursive. $Array[$Key] = Array_Walk2($Array[$Key], $Function); } Else // !Is_Array($Array[$Key]) { // It's a value, let's do our magic. Eval("\$Array[$Key] = $Function(\"$Array[$Key]\");"); } } Return $Array; } http://www.php.net/manual/function.array-walk.php

« previous php.notes (#9663) next »