note 95410 added to function.array-values
| From: | cmat | Date: | Fri, 01 Jan 2010 22:44:21 +0000 |
| Subject: | note 95410 added to function.array-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164524@lists.php.net to get a copy of this message | ||
Simple array_flatten that actually works...
takes a multi-dimensional array, and flattens into a zero indexed array.
function array_flatten($array, $flat = false)
{
if (!is_array($array) || empty($array)) return '';
if (empty($flat)) $flat = array();
foreach ($array as $key => $val) {
if (is_array($val)) $flat = array_flatten($val, $flat);
else $flat[] = $val;
}
return $flat;
}
----
Server IP: 69.147.83.197
Probable Submitter: 97.117.123.20
----
Manual Page -- http://www.php.net/manual/en/function.array-values.php
Edit -- https://master.php.net/note/edit/95410
Del: integrated -- https://master.php.net/note/delete/95410/integrated
Del: useless -- https://master.php.net/note/delete/95410/useless
Del: bad code -- https://master.php.net/note/delete/95410/bad+code
Del: spam -- https://master.php.net/note/delete/95410/spam
Del: non-english -- https://master.php.net/note/delete/95410/non-english
Del: in docs -- https://master.php.net/note/delete/95410/in+docs
Del: other reasons-- https://master.php.net/note/delete/95410
Reject -- https://master.php.net/note/reject/95410
Search -- https://master.php.net/manage/user-notes.php