note 100608 added to function.array-walk-recursive
| From: | rob at yurkowski dot net | Date: | Tue, 26 Oct 2010 18:16:04 +0000 |
| Subject: | note 100608 added to function.array-walk-recursive | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173476@lists.php.net to get a copy of this message | ||
If you don't really particularly care about the keys of an array, you can capture all values
quite simply:
<?php
$sample = array('dog' => 'woof', 'cat' =>
array('angry' => 'hiss', 'happy' => 'purr'),
'aardvark' => 'kssksskss');
$output = array();
// Push all $val onto $output.
array_walk_recursive($sample, create_function('$val, $key, $obj', 'array_push($obj,
$val);'), &output);
// Printing
echo nl2br(print_r($output, true));
/*
* Array
* (
* [0] => woof
* [1] => hiss
* [2] => purr
* [3] => kssksskss
* )
*/
?>
----
Server IP: 66.207.199.35
Probable Submitter: 70.76.32.210
----
Manual Page -- http://www.php.net/manual/en/function.array-walk-recursive.php
Edit -- https://master.php.net/note/edit/100608
Del: integrated -- https://master.php.net/note/delete/100608/integrated
Del: useless -- https://master.php.net/note/delete/100608/useless
Del: bad code -- https://master.php.net/note/delete/100608/bad+code
Del: spam -- https://master.php.net/note/delete/100608/spam
Del: non-english -- https://master.php.net/note/delete/100608/non-english
Del: in docs -- https://master.php.net/note/delete/100608/in+docs
Del: other reasons-- https://master.php.net/note/delete/100608
Reject -- https://master.php.net/note/reject/100608
Search -- https://master.php.net/manage/user-notes.php