Reputation: 677
I'm trying to echo value in PHP, which is stored in database using ckeditor, the value stored in database is something like
<p>sample text</p>
now im printing value using
<?php echo $row[0]->content; ?>
but the output I'm getting is
<p>sample text</p>
how to remove p tags from string?
Upvotes: 2
Views: 4415
Reputation: 54841
String <p>sample text</p>
includes some encoded html entities (<
for <
and >
for >
).
If you want to replace this encoded entitites with real symbols - use html_entity_decode
. After it, your string becomes <p>sample text</p>
. So if you echo it, <p>
and </p>
will be considered html-tags and will not be shown.
If you still need to remove these tags - use strip_tags
function.
In the end:
<?php echo strip_tags(html_entity_decode($row[0]->content)); ?>
And yes, strip_tags
removes all tags from a string unless you use it's second parameter.
Upvotes: 4