I am makeing a comment system, i have a string where i remove html code:

$area = stripslashes(htmlspecialchars($area));

But i replace text sometimes by code, but it doesn't work because of the code above:

$txtSmileys = array (':-)', ':-(');
$imgSmileys = array ('<img src="smiley.jpg" />', '<img src="smiley-sad.jpg" />');
$text = str_replace($txtSmileys, $imgSmileys, $text);

So how can i remove html before replacing?

Sanchixx

Reverse the order, replace the smileys first, then use the strip and special functions.

That doesn't work i've already tried it. :(

Have you ever tried to use JQUERY? :) could be helpful!

I solved it! I used htmlspecialchars_decode($Astring);

<?php
    $input = "<p>This is an example of random input you might encounter! :)</p>";

    $output = strip_tags($input);

    $output = str_replace (":)", "<img src=\"https://www.google.ca/intl/en_ALL/images/logos/images_logo_lg.gif\" alt=\"\"/>", $output);

    echo $output;
?>

Remember that you need the slashes infront of the quotes so that PHP ignores the quotes (because they're not really the end quotes).