Apply function to array nodes until not array nodes are arrays
<p>Let's say I have this structure, in an array:</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [0] =&gt; Heading1
            [1] =&gt; Array
                (
                    [0] =&gt; Array
                        (
                            [0] =&gt; 2
                            [1] =&gt; Heading2.1
                        )

                    [1] =&gt; Array
                        (
                            [0] =&gt; 2
                            [1] =&gt; Heading2.2
                        )

                )

        )

    [1] =&gt; Array
        (
            [0] =&gt; Heading1.2
        )

)
</code></pre>

<p>How do I go about applying a function only to the array elements holding heading2.1 and heading 2.2?</p>

<p>The function I want to apply may nest arrays even further. How can I make it so that my function will also run on these newly created arrays? And the arrays that are then created, until there are not arrays on the second deepest level?</p>
