$i++;
isn't executed when a smilie was found, only ("else") when no smilie was found.
code:
$i=0;
while ($i <= count($smileys_from)){
$pos = strpos($strUsername, $smileys_from[$i]);
if ($pos !== FALSE){
$imgEmote = imagecreatefrompng('resources/emotes/' . $smileys_to[$i] . '.png');
$emotepos = imagettfbboxext($nicksize, 'resources/font/'.$imgitem[$imgdata['nick_font']], substr($strUsername, 0, $pos));
imagecopyresized($imgBack, $imgEmote, $emotepos[4] + $imgdata['nick_x'] + $emoteoffsetx, $emotepos[7] + $imgdata['nick_y'] + $emoteoffsety, 0, 0, $emotesize, $emotesize, imagesx($imgEmote), imagesy($imgEmote));
$strUsername = str_replace_once($smileys_from[$i], $spacer, $strUsername);
imagedestroy($imgEmote);
}
$i++;
}