I'm trying to treat a string with the function str_replace
however I wanted to insert a <span>
before before the treated word, as in the example below:
$entrada = array("//");
$tratamento = array("<span class='comentario'>//</span>");
$saida = str_replace($entrada, $tratamento, $mensagem);
My question:
It is possible to do this with the function str_replace
, or only with regular expressions, if it is only with ER's you would like, please give me examples.
I wanted it to return something like this:
<span class='comentario'>//</span>
Thank you!