Recursive Function
<p>I have absolutely no idea, so if someone can point me in the right direction, it'd be greatly appreciated.</p>

<p>I want to have something like </p>

<pre><code>&lt;?php
function square($num) {
// something
}

name('{3}'); // have this return 9
name('{6}'); // have this return 36
name('{{{2}}}'); // have this return 256
name('{9}{12}'); // have this return 81144
name('{{5}}'); // have this return 125
name('adscdc{4}{{3}}'); // have this return adscdc1681
?&gt;
</code></pre>

<p>Does anyone have any idea how this can be done? Thanks in advance :)
So far, I have:</p>

<pre><code>&lt;?php
function square($text) {
    $parts = explode('{', $text);
    foreach($parts as $part) {
        $piece = explode('}', $part);
        $text = str_replace('{' . $piece[0] . '}', pow($piece[0], 2), $text);
    }
    return $text;
}
echo square('aasd{3}');
?&gt;
</code></pre>
