use Symfony\Component\String\UnicodeString; $text = 'This is a sample text.'; $unicodeText = new UnicodeString($text); $fullText = $unicodeText->getFullText(); echo $fullText; // Output: This is a sample text.
$html = 'In this example, we first create an HTML string and load it into the DOMDocument object. We then select the body element using the getElementsByTagName method and retrieve its full text content using the textContent property. Finally, we output the full text using the echo statement.Hello World!
'; $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')->item(0); $fullText = $body->textContent; echo $fullText; // Output: Hello World!