note 105877 added to function.array-walk-recursive
| From: | catoc at 163 dot com | Date: | Thu, 22 Sep 2011 03:04:01 +0000 |
| Subject: | note 105877 added to function.array-walk-recursive | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183343@lists.php.net to get a copy of this message | ||
tturner, just try this:
function test_array_walk_recursive()
{
$sample = array('dog' => 'woof', 'cat' =>
array('angry' => 'hiss', 'happy' => 'purr'),
'aardvark' => 'kssksskss');
$flattened = array();
$walkuserdata = array(&$flattened);
array_walk_recursive($sample, array($this, 'walkit'), $walkuserdata);
//array_walk_recursive($sample, array($this, 'walkit'), $flattened);
return($flattened);
}
function walkit($item, $key, $arr) // receive as reference here
//function walkit($item, $key, &$arr) // receive as reference here
{
array_push($arr[0], $item);
//array_push($arr, $item);
}
----
Server IP: 222.73.207.145
Probable Submitter: 127.0.0.1 (proxied: 124.79.250.44)
----
Manual Page -- http://www.php.net/manual/en/function.array-walk-recursive.php
Edit -- https://master.php.net/note/edit/105877
Del: integrated -- https://master.php.net/note/delete/105877/integrated
Del: useless -- https://master.php.net/note/delete/105877/useless
Del: bad code -- https://master.php.net/note/delete/105877/bad+code
Del: spam -- https://master.php.net/note/delete/105877/spam
Del: non-english -- https://master.php.net/note/delete/105877/non-english
Del: in docs -- https://master.php.net/note/delete/105877/in+docs
Del: other reasons-- https://master.php.net/note/delete/105877
Reject -- https://master.php.net/note/reject/105877
Search -- https://master.php.net/manage/user-notes.php