I have this in JavaScript:
msg = msg.replace(/(:\)|=\)|:-\)|\(:)/gi, "<img src='img/ei/1.png' class='ei' />");
Is there a similar way I can do that, but in PHP?
Thanks in advance, enji
I have this in JavaScript:
msg = msg.replace(/(:\)|=\)|:-\)|\(:)/gi, "<img src='img/ei/1.png' class='ei' />");
Is there a similar way I can do that, but in PHP?
Thanks in advance, enji
Exactly the same way:
$msg = preg_replace('/(:\)|=\)|:-\)|\(:)/i', "<img src='img/ei/1.png' class='ei' />", $msg);
If i understand correctly you are trying to replace instances of the :\ smiley with an image. You could do something like this:
<?php
$str = "Hey there :)";
str_replace(
array(":)", "=)", ":-)", "(:"),
"<img src='img/ei/1.png' class='ei' />",
$str);
?>
Shai.