note 104184 deleted from function.array-values by crell
| From: | crell@php.net | Date: | Tue, 12 Apr 2022 01:04:16 +0000 |
| Subject: | note 104184 deleted from function.array-values by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218180@lists.php.net to get a copy of this message | ||
Note Submitter: a dot ross at amdev dot eu
----
<?php
/**
* Flattens an array, or returns FALSE on fail.
*/
function array_flatten($array) {
if (!is_array($array)) {
return FALSE;
}
$result = array();
foreach ($array as $key => $value) {
if (is_array($value)) {
$result = array_merge($result, array_flatten($value));
}
else {
$result[$key] = $value;
}
}
return $result;
}
?>