How can HTML tags be removed from a string in PHP?

When working with strings that contain HTML tags in PHP, you may need to remove these tags to get plain text. One way to achieve this is by using the strip_tags() function in PHP. This function removes all HTML and PHP tags from a string, leaving only the plain text content.

<?php
$string_with_tags = "<p>This is a <strong>sample</strong> text with HTML tags.</p>";
$plain_text = strip_tags($string_with_tags);
echo $plain_text;
?>