How to extract arrays out of another array in PHP : <p>I have an array:</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [filePath] =&gt; 0000000023.jpg
        )

    [1] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [Label] =&gt; Array
                        (
                            [0] =&gt; Person
                            [1] =&gt; Person
                        )

                    [Score] =&gt; Array
                        (
                            [0] =&gt; 0.999217033
                            [1] =&gt; 0.999318361
                        )

                    [Coordinates] =&gt; Array
                        (
                            [0] =&gt; Array
                                (
                                    [0] =&gt; 338
                                    [1] =&gt; 430
                                    [2] =&gt; 307
                                    [3] =&gt; 506
                                )

                            [1] =&gt; Array
                                (
                                    [0] =&gt; 71
                                    [1] =&gt; 104
                                    [2] =&gt; 318
                                    [3] =&gt; 483
                                )

                        )

                )

        )

)
</code></pre>

<p>I need to make it to be look like this:</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [filePath] =&gt; 0000000023.jpg
        )

    [1] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [Label] =&gt; Person
                    [Score] =&gt; 0.999217033
                    [Coordinates] =&gt; 
                        [0] =&gt; Array
                                (
                                    [0] =&gt; 338
                                    [1] =&gt; 430
                                    [2] =&gt; 307
                                    [3] =&gt; 506
                                )
                )
            [1] =&gt; Array                     
                (
                    [Label] =&gt; Person
                    [Score] =&gt; 0.999318361
                    [Coordinates] =&gt; 
                        [0] =&gt; Array
                                (
                                    [0] =&gt; 71
                                    [1] =&gt; 104
                                    [2] =&gt; 318
                                    [3] =&gt; 483
                                )
                )

        )

)
</code></pre>

<p>In Ruby I can use map and select to get the result however in PHP I can't figure it out. I managed to do it with <code>Foreach</code> loop however it is very ugly and lots of if statement. </p>

<p>I'd appreciate any guidance. </p>
