public static function listToMultiArray($array)
    {
        $nested = [];
        $depths = [];

        foreach ($array as $key => $arr) {

            if ($arr['depth'] == 0) {
                $nested[$key] = $arr;
            } else {
                $parent =& $nested;

                for ($i = 1; $i <= ($arr['depth']); $i++) {
                    $parent =& $parent[$depths[$i]];
                }

                $parent['pages'][$key] = $arr;
            }

            $depths[$arr['depth'] + 1] = $key;
        }

        return $nested;
    }
public static function listToMultiArray($array)
    {
        $nested = [];
        $depths = [];

        foreach ($array as $key => $arr) {

            if ($arr['depth'] == 0) {
                $nested[$key] = $arr;
            } else {
                $parent =& $nested;

                for ($i = 1; $i <= ($arr['depth']); $i++) {
                    $parent =& $parent[$depths[$i]];
                }

                $parent['pages'][$key] = $arr;
            }

            $depths[$arr['depth'] + 1] = $key;
        }

        return $nested;
    }
public static function listToMultiArray ( $ array ) { $ nested = [ ] ; $ depths = [ ] ; foreach ( $ array as $ key => $ arr ) { if ( $ arr [ 'depth' ] == 0 ) { $ nested [ $ key ] = $ arr ; } else { $ parent = & $ nested ; for ( $ i = 1 ; $ i <= ( $ arr [ 'depth' ] ) ; $ i ++ ) { $ parent = & $ parent [ $ depths [ $ i ] ] ; } $ parent [ 'pages' ] [ $ key ] = $ arr ; } $ depths [ $ arr [ 'depth' ] + 1 ] = $ key ; } return $ nested ; }
transform a list into a multidimensional array
using a depth value

@param array $array
@return array
transform a list into a multidimensional array using a depth value