How to output an array based on primary keys and foreign keys
<p>Considering this array</p>

<pre><code>Array
(
[0] =&gt; Array
    (
        [id] =&gt; 51
        [category_id] =&gt; 37
        [title] =&gt; Sims
    )

[1] =&gt; Array
    (
        [id] =&gt; 37
        [category_id] =&gt; 26
        [title] =&gt; Blackberry
    )

[2] =&gt; Array
    (
        [id] =&gt; 26
        [category_id] =&gt; 0
        [title] =&gt; Mobile Device
    )
</code></pre>

<p>I would like to be able to print out:</p>

<pre><code>Mobile Device &gt; Blackberry &gt; Sims
</code></pre>

<p>Based on the relationship between category_id and id.</p>
