UBB / Smileys won't replace sometime
<p>With the code below some smilies won't work (the text isn't replaced by a smiley). When I change the order of the $smileys array, the broken smileys work but others don't.</p>

<p>So I know the order of the $smileys array determines the replacement of the smilies, but I don't know why.</p>

<p>Can anybody help me to let all the smileys work properly? Thanks</p>

<pre><code>public $smileys = array(
    'tongetje.gif'  =&gt; array(':p',':P'),
    'cool.gif'  =&gt; array(':8'),
    'dansen.gif'=&gt; array('(dance)'),
    'mondje_dicht.gif' =&gt; array(':|'),
    'muur_hoofd.gif'    =&gt; array('|:('),
    'huilen.gif'    =&gt; array('(h)'),
    'loser.gif' =&gt; array('(:)'),
    'lachje.gif' =&gt; array(':)',':-)'),
    'wink.gif'  =&gt; array(';)'),
    'lach.gif'  =&gt; array(':d',':-D'),
    'lollol.gif'    =&gt; array(':#'),
    'bloos.gif' =&gt; array('(b)'),
    'stom.gif'  =&gt; array(':s'),
    'doei.gif'  =&gt; array('(d)'),
    'engeltje.gif' =&gt; array('O-)'),
    'boze_smiley.gif' =&gt; array(':('),
    '1april.gif' =&gt; array(':1)'),
    'koning.gif' =&gt; array('(koning)'),
    'offtopic.gif' =&gt; array('*-*'),
    'opgeven_verlegen.gif' =&gt; array('O+'),
     'piraat.gif' =&gt; array(':F'),
    'politie.gif' =&gt; array('(p)'),
    'reggae.gif' =&gt; array('(r)'),
    'jammie.gif' =&gt; array(':9'),
    'schamen.gif' =&gt; array(':-8'),
    'verliefd.gif' =&gt; array(':00'),
    'middelvinger.gif' =&gt; array(':--')
);      

private function ubb_smileys($string) {
    $counter = 1;
    foreach($this-&gt;smileys as $imagename =&gt; $imagetags) {
        if(is_numeric($this-&gt;smilies_enable)) {
            if($counter &lt;= $this-&gt;smilies_enable) {
                foreach($imagetags as $int =&gt; $tag) {
                    $tag = str_replace("\\", "", $tag);
                    $src = UBB_SMILEYS_PATH.$imagename;
                    $image = UBB_SMILEYS_STRING;
                    $image = str_replace('${TAG}', $tag, $image);
                    $image = str_replace('${SRC}', $src, $image);
                    $string = str_replace($tag, $image, $string);

                }
            }
        } else {
            foreach($imagetags as $int =&gt; $tag) {
                $tag = str_replace("\\", "", $tag);
                $src = UBB_SMILEYS_PATH.$imagename;
                $image = UBB_SMILEYS_STRING;
                $image = str_replace('${TAG}', $tag, $image);
                $image = str_replace('${SRC}', $src, $image);
                $string = str_replace($tag, $image, $string);

            }
        }
        $counter++;
    }
    return $string;
}
</code></pre>
