note 59984 deleted from function.array-walk-recursive by crell

From: Date: Tue, 12 Apr 2022 01:07:38 +0000
Subject: note 59984 deleted from function.array-walk-recursive by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218205@lists.php.net to get a copy of this message
Note Submitter: omega13a at sbcglobal dot net ---- This is a peice of code I wrote that appears to create this function for PHP 4. <?php if (!function_exists('array_walk_recursive')) { function array_walk_recursive(&$input, $funcname, $userdata = "") { if (!is_callable($funcname)) { return false; } if (!is_array($input)) { return false; } foreach ($input AS $key => $value) { if (is_array($input[$key])) { array_walk_recursive($input[$key], $funcname, $userdata); } else { $saved_value = $value; if (!empty($userdata)) { $funcname($value, $key, $userdata); } else { $funcname($value, $key); } if ($value != $saved_value) { $input[$key] = $value; } } } return true; } } ?> Please note it is a conditionaly set function and will have to be put before any call to it. If there is anything wrong with it, please email me.

« previous php.notes (#218205) next »