How to retrieve the contents of the HTML tag.
$foo = '<p>
aaaaaa </p>
<p>
bbbbbb bb
bbbbbbb </p>
<p> cccccccc
ccc</p>';
I need to get "aaaaaa"
thank you very much
How to retrieve the contents of the HTML tag.
$foo = '<p>
aaaaaa </p>
<p>
bbbbbb bb
bbbbbbb </p>
<p> cccccccc
ccc</p>';
I need to get "aaaaaa"
thank you very much
Use a DOMParser
echo trim($dom->getElementsByTagName('p')->item(0)->nodeValue); //"prints" aaaaaa
Use this:
$content = null ;
if ( preg_match("/<p[^>]*>(.*?)<\\/p>/si", $foo, $match) )
$content = $match[1];
use $match[2] for the second match, etc.