generate functionThu, 22 Dec 2022

extract paragraphs from html string

<?php function extractParagraphs($html) { $paragraphs = array(); $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->loadHTML($html); libxml_clear_errors(); foreach ($doc->getElementsByTagName('p') as $node) { $paragraphs[] = trim($node->nodeValue); } return $paragraphs; }

Want to kickstart your project?Use the new AI Studio to create your code