1<?php
2
3/**
4 * Convert a multi-dimensional array into a single-dimensional array.
5 * @author Sean Cannon, LitmusBox.com | seanc@litmusbox.com
6 * @param array $array The multi-dimensional array.
7 * @return array
8 */
9function array_flatten($array) {
10 if (!is_array($array)) {
11 return false;
12 }
13 $result = array();
14 foreach ($array as $key => $value) {
15 if (is_array($value)) {
16 $result = array_merge($result, array_flatten($value));
17 } else {
18 $result = array_merge($result, array($key => $value));
19 }
20 }
21 return $result;
22}