How to remove the HTML tags?
I want to remove the HTML tags in the PDF view. Look at the picture below. Please help me with this.
This is my code:
$string1 = $_POST["editor1"];
$string1 = str_replace("<p>", "", $string1);
$string2 = str_replace(" ", " ", $string1);
$string2 = explode("</p>", $string1);
This is my output:
foreach ($string2 as $key) {
$pdf->Multicell(0,3,$key);
}
?>
The strip_tags()
function strips a string from HTML, XML, and PHP tags.
strip_tags(string,allow)
$string1 = strip_tags($string1);
*Update
-Allowing certain tags to be get printed.
echo strip_tags("Hello <b><i>SO!</i></b>","<b>");
prints Hello SO!
You could use following code for replacement of special characters in pdf formatted text. I have used this code in my java project, and it is working fine there. I have changed this to php for you.
$string1=str_replace(" ", " ", $string1 );
$string1=str_replace("&", "&", $string1 );
$string1=str_replace(">", ">", $string1 );
$string1=str_replace("<", "<", $string1 );
$string1=str_replace("à", "À", $string1 );
$string1=str_replace("ë", "Ë", $string1 );
$string1=str_replace("\"", """, $string1 );
$string1=str_replace("<br />", "<br />", $string1 );
$string1=str_replace("é", "é", $string1 );
$string1=str_replace("à", "à", $string1 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With