To extract text from HTML, you can use PHP's built-in DOMDocument class. Here's an example:
$html = '<p>Hello,</p>
<p>I need to use a service like nlpcloud.com API to paraphrase some text.</p>
<p>My client wants to submit an HTML content and I need to extract the texts from inside the tags, then paraphrase each part of text and reinject the paraphrased texts inside the tags at the right place.</p>
<p>I already have an idea how to do that.</p>
<p>What would you suggest me ?</p>
<p>Thanks for your answer.</p>
<p>V</p>';
$dom = new DOMDocument();
$dom->loadHTML($html);
$text = '';
foreach ($dom->getElementsByTagName('p') as $p) {
$text .= $p->textContent;
}
echo $text;
This code will extract all the text content from the <p> tags in the HTML and concatenate them into a single string. You can then use this string with the nlpcloud.com API to paraphrase the text. Once you have the paraphrased text, you can use the DOMDocument class again to replace the original text with the new text.