note 105877 deleted from function.array-walk-recursive by danbrown
| From: | danbrown@php.net | Date: | Thu, 22 Sep 2011 15:19:37 +0000 |
| Subject: | note 105877 deleted from function.array-walk-recursive by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183345@lists.php.net to get a copy of this message | ||
Note Submitter: catoc at 163 dot com
----
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);
}