note 104183 deleted from function.array-values by thiago

From: Date: Tue, 31 May 2011 03:38:17 +0000
Subject: note 104183 deleted from function.array-values by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180104@lists.php.net to get a copy of this message
Note Submitter: a dot ross at amdev dot eu ---- <?php // It would make more sense to use array_merge() when recursively calling array_flatten(). /** * Flattens an array, or returns FALSE on fail. */ function adhan_flatten($array) { if (!is_array($array)) { return FALSE; } $result = array(); foreach ($array as $key => $value) { if (is_array($value)) { $result = array_merge($result, adhan_flatten($value)); } else { $result[$key] = $value; } } return $result; } ?>

« previous php.notes (#180104) next »