public static function flatten(array $array, $prefix = '', $join = '.')
    {
        $flat = array();

        foreach ($array as $key => $value) {
            $key = $prefix ? $prefix . $join . $key : $key;

            if (is_array($value)) {
                $flat = array_merge(
                    $flat,
                    self::flatten($value, $key, $join)
                );
            } else {
                $flat[$key] = $value;
            }
        }

        return $flat;
    }