Am I right in thinking this loop below is to weed out any conflicts between the emoticons:
code:
for ($i = 0; $i < $e_keys_size; $i++) {
for ($j = 0; $j < $e_keys_size; $j++) {
if ($i != $j) {
if (($pos = strpos(strtolower($e_keys[$j]), strtolower($e_keys[$i]))) !== false) {
$a = $e_keys[$j];
$b = $e_keys[$i];
$v = $emoticon[$a];
$a2 = urlencode($a);
$a_f = preg_quote(substr($a, 0, $pos), "/");
$a_m = preg_quote(urlencode(substr($a, $pos, strlen($b))), "/");
$a_e = preg_quote(substr($a, $pos +strlen($b)), "/");
$pattern_array[] = "/". $a_f."<span class=[^>]+><span[^>]*>".$a_m."<\/span><\/span>".$a_e ."/";
$replace_array[] = "<span class=\"e_$v\" title=\"$a2\"><span class=\"e__\">$a2</span></span>";
}
}
}
}
So it will find :o and :o) and ensure that :o) is matched before :o so :o doesn't replace :o) and leave us with a stray closing bracket and the wrong emoticon showing?
Right?
I'm wondering if the same could be accomplished by simply sorting the emoticon match text array by length with the longest first? Could do that with a single function call see.
Or am I way off base as to what that loop does?