Suppose string $a holds
Phasellus blandit enim eget odio euismod eu dictum quam scelerisque.
Sed ut diam nisi.
Ut v
<?php
$ps = array();
$count = preg_match_all('/<p[^>]*>(.*?)<\/p>/is', $a, $matches);
for ($i = 0; $i < $count; ++$i) {
$ps[] = $matches[0][$i];
}
That could be one way. Or you could use a loop with strpos
Using DOMDocument and DOMXPath (a bit overkill if only a simple solution is needed):
$dom = new DOMDocument();
$dom->loadHTML($a);
$domx = new DOMXPath($dom);
$entries = $domx->evaluate("//p");
$arr = array();
foreach ($entries as $entry) {
$arr[] = '<' . $entry->tagName . '>' . $entry->nodeValue . '</' . $entry->tagName . '>';
}
print_r($arr);