Ok, I run a simple query,
SELECT description
FROM TABLE
WHERE id = 111;
in my results, I get:
<p>Blah blah description is here blah blah<p>
Then when I output my results with PHP using:
echo '<ul>' . $row['description'] . '</ul>';
I get this on my html page:
<p>Blah blah description is here blah blah</p>
How can I get rid of the <p>
tags at the beginning and end of my description? I am using concrete5 for my page if that helps. Thanks!
You can use strip_tags
to get rid of HTML.
$string = "<p>Blah blah description is here blah blah<p>";
$string = html_entity_decode($string);
$string = strip_tags($string);
echo $string; // Blah blah description is here blah blah
You shouldn't typically store HTML in the database though. Unless the input is coming from a source like a WYSIWYG you will want to store plaintext. This smells like a case where plaintext was needed.
Those are encoded html entities. to get rid of them you may do this:
echo strip_tags(html_entity_decode($yourString));
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