i have this codes for show smileys
$C->POST_ICONS = array (
':)' => 's1.gif',
':))' => 's33.gif',
)
and for classes use :
foreach($C->POST_ICONS as $k=>$v) {
$message = str_replace($k, '<img src="'.$C->IMG_URL.'icons/'.$v.'" class="post_smiley" alt="'.$k.'" title="'.$k.'" rel="tooltip" />', $message);
}
problem : when i post :)) just show s1.gif and ) ! but should show s33.gif
This'll never work. Consider this:
$message = "HI :))";
You run your loop, and iterate through all the options. First up is :)
, so $message becomes:
HI <img src="s1.gif" class="post_smiley alt=":)" title=":) etc...>)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-- originally :)
^--- leftover )
Now you come to :))
and it doesn't exist in your string anymore.
Going the other way, replacing :))
first, then :)
is even worse. You'll end up with
HI <img src="s33.gif" .... alt="<img src="s1.gif" .... alt=":)" >>
^^^^^---oops. img tag INSIDE another img tag.
You cannot do blind string replacements like this, where some of the replacement strings are subsets of other strings. You'll end up nesting replacements inside replacements inside replacements etc... and just end up with a huge incredibly broken pile of bad html.
$C->POST_ICONS = array (
':))' => 's33.gif',
':)' => 's1.gif',
)
Try this this might solve your problem.