src/helpers/ArrayHelper.php
public static function reverse_flatten($array, $glue = ':')
    {
        $return = [];
        foreach ($array as $key => $value) {
            if (stripos($key, $glue) !== false) {
                $keys = explode($glue, $key);
                $temp =& $return;
                while (count($keys) > 1) {
                    $key = array_shift($keys);
                    $key = is_numeric($key) ? (int) $key : $key;
                    if (!isset($temp[$key]) or !is_array($temp[$key])) {
                        $temp[$key] = [];
                    }
                    $temp =& $temp[$key];
                }
                $key = array_shift($keys);
                $key = is_numeric($key) ? (int) $key : $key;
                $temp[$key] = $value;
            } else {
                $key = is_numeric($key) ? (int) $key : $key;
                $return[$key] = $value;
            }
        }
        return $return;
    }
public static function reverse_flatten($array, $glue = ':')
    {
        $return = [];
        foreach ($array as $key => $value) {
            if (stripos($key, $glue) !== false) {
                $keys = explode($glue, $key);
                $temp =& $return;
                while (count($keys) > 1) {
                    $key = array_shift($keys);
                    $key = is_numeric($key) ? (int) $key : $key;
                    if (!isset($temp[$key]) or !is_array($temp[$key])) {
                        $temp[$key] = [];
                    }
                    $temp =& $temp[$key];
                }
                $key = array_shift($keys);
                $key = is_numeric($key) ? (int) $key : $key;
                $temp[$key] = $value;
            } else {
                $key = is_numeric($key) ? (int) $key : $key;
                $return[$key] = $value;
            }
        }
        return $return;
    }
public static function reverse_flatten ( $ array , $ glue = ':' ) { $ return = [ ] ; foreach ( $ array as $ key => $ value ) { if ( stripos ( $ key , $ glue ) !== false ) { $ keys = explode ( $ glue , $ key ) ; $ temp = & $ return ; while ( count ( $ keys ) > 1 ) { $ key = array_shift ( $ keys ) ; $ key = is_numeric ( $ key ) ? ( int ) $ key : $ key ; if ( ! isset ( $ temp [ $ key ] ) or ! is_array ( $ temp [ $ key ] ) ) { $ temp [ $ key ] = [ ] ; } $ temp = & $ temp [ $ key ] ; } $ key = array_shift ( $ keys ) ; $ key = is_numeric ( $ key ) ? ( int ) $ key : $ key ; $ temp [ $ key ] = $ value ; } else { $ key = is_numeric ( $ key ) ? ( int ) $ key : $ key ; $ return [ $ key ] = $ value ; } } return $ return ; }
Reverse a flattened array in its original form.
@param   array  $array flattened array.
@param   string $glue  glue used in flattening.
@return  array the unflattened array
Reverse a flattened array in its original form .