note 70194 added to function.create-function
| From: | Phlyst at osu1 dot php dot net | Date: | Fri, 06 Oct 2006 12:10:23 +0000 |
| Subject: | note 70194 added to function.create-function | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118124@lists.php.net to get a copy of this message | ||
In reply to info at adaniels dot nl:
You may not be able to use __FUNCTION__ in a lambda (thanks for pointing it out; I was having that
problem just now), but you can use $GLOBALS to work around it if you're assigning the function
to a variable. I reimplemented array_walk_recursive() in PHP4 like this:
<?php
$array_walk_recursive = create_function('&$array, $callback',
'foreach($array as $element) {
if(is_array($element)) {
$funky = $GLOBALS["array_walk_recursive"];
$funky($element, $callback);
}
else {
$callback($element);
}
}');
?>
----
Server IP: 66.163.161.117
Probable Submitter: 65.38.194.130
----
Manual Page -- http://www.php.net/manual/en/function.create-function.php
Edit -- https://master.php.net/note/edit/70194
Del: integrated -- https://master.php.net/note/delete/70194/integrated
Del: useless -- https://master.php.net/note/delete/70194/useless
Del: bad code -- https://master.php.net/note/delete/70194/bad+code
Del: spam -- https://master.php.net/note/delete/70194/spam
Del: non-english -- https://master.php.net/note/delete/70194/non-english
Del: in docs -- https://master.php.net/note/delete/70194/in+docs
Del: other reasons-- https://master.php.net/note/delete/70194
Reject -- https://master.php.net/note/reject/70194
Search -- https://master.php.net/manage/user-notes.php