note 59984 added to function.array-walk-recursive

From: Date: Thu, 22 Dec 2005 00:21:17 +0000
Subject: note 59984 added to function.array-walk-recursive
Groups: php.notes 
Request: Send a blank email to php-notes+get-100554@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.array-walk-recursive.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59984 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59984&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59984&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59984&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59984&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59984&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59984&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59984&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59984&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100554) next »