Merges the given configurations into a single configuration array.
@param array $array the configurations to merge.
@return array the merged configuration.
429459
public static function merge(array $array)
    {
        $result = array();
        foreach ($array as $config) {
            if (is_string($config)) {
                if (!file_exists($config)) {
                    continue;
                }
                $config = require($config);
            }
            if (!is_array($config)) {
                continue;
            }
            $result = self::mergeArray($result, $config);
        }
        return $result;
    }
651619
private function _convertDottedPropertiesToArray(&$array)
    {
        foreach ($array as $section => $sectionArray) {

            $merged = array();

            foreach ($sectionArray as $key => $value) {

                $property = $this->_dotToArray($key, $value);
                $merged = array_merge_recursive($merged, $property);
            }

            $array[$section] = $merged;
        }
    }
269632
private function arrayFlatten(array $array)
    {
        $flat = array();
        foreach ($array as $arg) {
            switch (gettype($arg)) {
                case 'array':
                    $flat = array_merge($flat, $arg);
                    break;

                default:
                    $flat[] = $arg;
                    break;
            }
        }

        return $flat;
    }
1110967
public static function flatten($array = [])
    {
        $items = [];
        foreach ($array as $value) {
            if (is_array($value)) {
                $items = array_merge($items, self::flatten($value));
            } else {
                $items[] = $value;
            }
        }
        return $items;
    }
79161
public static function convertToOneDimensionalArray($array)
    {
        $newArray = array();
        if (is_array($array))
        {
            foreach ($array as $value)
            {
                $newArray = array_merge($newArray, self::convertToOneDimensionalArray($value));
            }
        } else
        {
            $newArray[] = $array;
        }

        return $newArray;
    }
157566
public static function flatten(array $array)
    {
        $out = [];

        foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key => $item) {
            if (is_int($key)) {
                $out[] = $item;
            } else {
                $out[$key] = $item;
            }
        }

        return $out;
    }
162994
public static function flat(array $array)
    {
        $out = [];
        foreach ($array as $key=>$value) {
            if (is_array($value)) {
                //use recursion to get to the next array
                $out = array_merge($out, self::flat($value));
            } else {
                //add the value to the back of the array
                //if the value is not an array
                $out[] = $value;
            }
        }
        //return the resulting array
        return $out;
    }
328898
public static function createFromArray(array $array): self
    {
        $map = new self;

        foreach ($array as $key => $value) {
            $map->put($key, $value);
        }

        return $map;
    }
207622
public static function collapse($array)
    {
        $results = [];

        foreach ($array as $values) {
            if ($values instanceof Collection) {
                $values = $values->all();
            } elseif (! is_array($values)) {
                continue;
            }

            $results = array_merge($results, $values);
        }

        return $results;
    }
829643
protected function mergeBindings(array ...$arrays): array {
		
		// at first blush, it seems like one could use something like array_merge()
		// to build our return value, but because that method would overwrite matching
		// keys in early arrays with values in the latter ones, we can't rely on it.
		// instead, what we actually want to do is flatten our $arrays which we've
		// learned to do here: http://stackoverflow.com/a/1320156/360838.
		
		$bindings = [];
		
		array_walk_recursive($arrays, function($x) use (&$bindings) {
			$bindings[] = $x;
		});
		
		return $bindings;
	}
16143
public static function collapse($array)
	{
		$results = [];
		foreach ($array as $values)
		{
			if ($values instanceof Collection)
			{
				$values = $values->getAll();
			}
			elseif (! is_array($values))
			{
				continue;
			}
			$results = array_merge($results, $values);
		}
		return $results;
	}
1146570
static protected function flattenArray( $array )
    {
        if ( !is_array( $array ) )
        {
            return array( $array );
        }

        $arrayFlatten = array();
        while( !empty( $array ) )
        {
             $item = array_shift( $array );
             if ( is_array( $item ) )
                 $array = array_merge( $item, $array );
             else
                 $arrayFlatten[] = $item;
        }
        return $arrayFlatten;
    }
1332324
public static function mergeSort($array): array
    {
        if (count($array) === 1) {
            return $array;
        }

        $middle = (int)round(count($array) / 2);
        $left = array_slice($array, 0, $middle);
        $right = array_slice($array, $middle);

        $left = self::mergeSort($left);
        $right = self::mergeSort($right);

        return self::merge($left, $right);
    }
229184
public function normalizeArray(array $array)
    {
        $normal = [];

        foreach ($array as $action => $config) {
            if (is_string($config)) {
                $config = ['className' => $config];
            }

            if (is_int($action)) {
                list(, $action) = pluginSplit($config['className']);
            }

            $action = Inflector::variable($action);
            $normal[$action] = $config;
        }

        return $normal;
    }
377506
public static function array_merge_deep(array $array1, array $array2)
	{
		$merged = $array1;

		foreach ($array2 as $key => $value) {
			if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
				$merged[$key] = self::array_merge_deep($merged[$key], $value);
			} elseif (is_numeric($key)) {
				// Numeric key. Look at values instead of keys to determine if it already exists.
				if (!in_array($value, $merged)) {
					$merged[] = $value;
				}
			} else {
				$merged[$key] = $value;
			}

		}

		return $merged;
	}
260471
public function flatter($array)
    {
        $result = [];
        foreach ($array as $item) {
            if (is_array($item)) {
                $result = array_merge($result, $this->flatter($item));
            } else {
                $result[] = $item;
            }
        }

        return $result;
    }
855914
public static function expand(array $array): array
    {
        $results = [];

        foreach ($array as $key => $value) {
            static::set($results, $key, $value);
        }

        return $results;
    }