PHP how to make complex large array simple : <p>Hi I'd like to make complex array simple to use in view.</p>

<p>However, I'm kind of stuck making a loop</p>

<p>Please see what i misunderstand about array</p>

<p>I want this array simple</p>

<pre><code>'collection' =&gt; [
    (int) 0 =&gt; [
        'type' =&gt; 'col',
        'name' =&gt; '2016 F/W',
        'url' =&gt; 'blablabla'
    ],
    (int) 1 =&gt; [
        'type' =&gt; 'col',
        'name' =&gt; '2015 F/W',
        'url' =&gt; 'blablabla'
    ],
    (int) 2 =&gt; [
        'type' =&gt; 'project',
        'name' =&gt; '2015 F/W',
        'url' =&gt; 'blablabla'
    ]
]
</code></pre>

<p>and I want this array like this</p>

<pre><code>[
(int) 0 =&gt; [
    'type' =&gt; 'col',
    'type2' =&gt; [
        (int) 0 =&gt; [
            'name' =&gt; '2016 F/W',
            'image' =&gt; [
                (int) 0 =&gt; [
                    'url' =&gt; null
                ],
                (int) 1 =&gt; [
                    'url' =&gt; null
                ]
            ]
        ],
        (int) 1 =&gt; [
            'name' =&gt; '2015 F/W',
            'image' =&gt; [
                (int) 0 =&gt; [
                    'url' =&gt; null
                ]
            ]
        ]
    ]
],
(int) 1 =&gt; [
    'type' =&gt; 'project',
    'type2' =&gt; [
        (int) 0 =&gt; [
            'name' =&gt; '2015 F/W',
            'image' =&gt; [
                (int) 0 =&gt; [
                    'url' =&gt; null
                ]
            ]
        ],
    ]
]
</code></pre>

<p>Please Help!! I'm almost going crazy!!!!</p>
