What are some alternative approaches to displaying partial HTML content in PHP search results?

When displaying search results in PHP, it is common to show a snippet of the content that matches the search query. One way to achieve this is by using the `strip_tags` function to remove HTML tags and then limiting the length of the text displayed. Another approach is to use regular expressions to extract a specific portion of the content.

// Example of displaying partial HTML content in PHP search results using strip_tags and substr
$searchQuery = "example";
$content = "<p>This is an example of displaying partial HTML content in PHP search results.</p>";

// Remove HTML tags and limit the length of the text displayed
$strippedContent = strip_tags($content);
$snippet = substr($strippedContent, 0, 50) . "...";

echo $snippet;