How to extract content between specific HTML tag in PHP

1 Answer

0 votes
$html = '<h1 class="text-decor">PHP Programming</h1>';

preg_match('/<h1 class="text-decor">(.*?)<\/h1>/s', $html, $match);

echo $match[0];
echo $match[1];



/*
run:
           
PHP Programming
PHP Programming
 
*/

 



answered Sep 21, 2019 by avibootz
...