In PHP, how to remove HTML tags from a string?
The PHP function strip_tags() removes HTML, XML and PHP tags from a string. Here is an example where all the tags are deleted
$string = "<h1>Title</h1>";
// Displays: Title
echo strip_tags ($string);
The following example removes all the tags except <b> and <i> :
$string = '<div><b>Bold</b> and <i>italic</i> text</div>';
// Dispays: <b>Bold</b> and <i>italic</i> text
echo strip_tags ($string, '<b><i>');
See also:
The PHP function strip_tags() removes HTML, XML and PHP tags from a string. Here is an example where all the tags are deleted
$string = "<h1>Title</h1>";
// Displays: Title
echo strip_tags ($string);
The following example removes all the tags except <b> and <i> :
$string = '<div><b>Bold</b> and <i>italic</i> text</div>';
// Dispays: <b>Bold</b> and <i>italic</i> text
echo strip_tags ($string, '<b><i>');
See also:
The PHP function strip_tags() removes HTML, XML and PHP tags from a string. Here is an example where all the tags are deleted
$string = "<h1>Title</h1>";
// Displays: Title
echo strip_tags ($string);
The following example removes all the tags except <b> and <i> :
$string = '<div><b>Bold</b> and <i>italic</i> text</div>';
// Dispays: <b>Bold</b> and <i>italic</i> text
echo strip_tags ($string, '<b><i>');
Voire aussi :
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 12419 | en | https://en.ans.wiki/6177/in-php-how-to-remove-html-tags-from-a-string | 8 |