I am explaining you, how to extract data/content between HTML Tags in PHP.
preg_match() function provide functionality to extract text between HTML tags with REGEX in PHP. we can get content between tags with the use of regular expressions with preg_match() function in PHP.
Example :
<?php
$htmlwithtext = '<div class="checkdata">This is webdeveloperindia group.</div>';
preg_match('/<div class="checkdata">(.*?)<\/div>/s', $htmlwithtext, $matchdata);
echo "<br>";
echo $matchdata[0];
echo "<br>";
echo $matchdata[1];
?>
we can find result will be stored in $matchdata variable. if you will run the code then you should inspect the element to see the difference between $matchdata[0] and $matchdata[1].
Extract the content, including the parent html element tags:
echo $matchdata[0];
Output :
<div class="checkdata">This is webdeveloperindia group.</div>
Extract the content between html tags:
echo $match[1];
Output :
This is webdeveloperindia group.
Hello, Welcome to webdeveloperindia.in. I am a full-stack web developer. Email – [email protected] | Skype – azaruddin23. I have knowledge of PHP, Laravel, Magento 1/2, Codeigniter, WordPress, Joomla, Shopify, Git, Bitbuket, jQuery, Ajax, Javascript and ReactJS.
i am looking for some modifications on my website entiretools.com its built on PHP and MySQL,