Forum Moderators: coopster
I'm trying to debug a third party regex script used to display smileys, and while it works, it won't display the same smiley more than twice in a row. Here's the code I'm looking at:
function lmbbox_smileys_comment_convert($text) {
global $lmbbox_smileys;
return preg_replace($lmbbox_smileys->comment_smileys['search'], $lmbbox_smileys->comment_smileys['replace'], $text);
}
Here's the array I think it's using:
foreach ($info['smileys'] as $smiley => $img) {
if (!in_array($img, $info['disabled']['comment'])) {
$this->comment_smileys['search'][] = '/(^¦\s)' . preg_quote($smiley) . '(\s¦\W¦$)/';
$this->comment_smileys['replace'][] = '\\1<img class="lmbbox_smileys_img" src="' . $this->manage['smileys_url_path'] . $smileys . '/' . $img . '" alt="' . htmlspecialchars(trim($smiley) , ENT_QUOTES) . '" />\\2';
For those familiar with preg_replace, any idea why it won't replace the same smiley more than twice in a row? If I use the same three smileys for example, the first and third smiley will be replaced, but the second remains unchanged. Drives me nuts. :-P
Any help or guidance appreciated!
$this->comment_smileys['search'][] = '/'.preg_quote($smiley).'/';