Sort multidimensional array by multidimensional array value
<p>I want to use the 'id' array of Array 1 to order all other sibling arrays in Array 2. The 'id' array is supposed to act as the schema for all other arrays in <code>$array1</code> and <code>$array2</code>. </p>

<p>This is easier explained with an example.</p>

<p>I have the following array, Array 1 :</p>

<pre><code>Array
(
    [id] =&gt; Array
        (
            [0] =&gt; 1
            [1] =&gt; 3
            [2] =&gt; 2
        )

    [headline] =&gt; Array
        (
            [0] =&gt; test 1
            [1] =&gt; test 3
            [2] =&gt; test 2
        )
)
</code></pre>

<p>And another array, Array 2:</p>

<pre><code>Array
(
    [id] =&gt; Array
        (
            [0] =&gt; 1
            [1] =&gt; 2
            [2] =&gt; 3
        )

    [headline] =&gt; Array
        (
            [0] =&gt; tc test 1
            [1] =&gt; tc test 2
            [2] =&gt; tc test 3
        )
)
</code></pre>

<p>That I would like to look like the following:</p>

<pre><code>Array
(
    [id] =&gt; Array
        (
            [0] =&gt; 1
            [1] =&gt; 3
            [2] =&gt; 2
        )

    [headline] =&gt; Array
        (
            [0] =&gt; tc test 1
            [1] =&gt; tc test 3
            [2] =&gt; tc test 2
        )

)
</code></pre>

<p>Right now I'm trying to force it with foreach statements (and failing), but there has to be a better way. </p>