kord
answered Apr 25 '23 00:00
If strip_tags () is removing everything from your string, it's likely that your input string doesn't contain any valid HTML tags.
The strip_tags () function removes any HTML tags and their attributes from a string. If the input string doesn't contain any HTML tags, then the function will return an empty string.
Here's an example of how strip_tags () works:
// Input string with HTML tags
$input_string = '<p>This is some <strong>bold text</strong>.</p>';
// Remove all HTML tags
$filtered_string = strip_tags($input_string);
// Output the filtered string
echo $filtered_string;
In this example, the output will be:
This is some bold text.
However, if the input string doesn't contain any HTML tags, the function will return an empty string:
// Input string with no HTML tags