I am using this code for removing anchor tag and also to get only inner text using expression
<ul class="alpha">
<li><h3><a href="http://www.overstock.com/Electronics/Computers-Tablets/473/dept.html?TID=TN:ELEC:Comp">Computers & Tablets</a></h3></li>
<li><a href="http://www.overstock.com/Electronics/2-in-1s/28195/subcat.html?TID=TN:ELEC:2in1">2-in-1s</a></li>
<li><a href="http://www.overstock.com/Electronics/Laptops/133/subcat.html?TID=TN:ELEC:Lap">Laptops</a></li>
</ul>
Expression is:
echo preg_replace('#<a.*?>([^>]*)</a>#i', '$1', $str);
Output is:
Computers & Tablets
2-in-1s
Laptops
Can we get inner text inside anchor tag in an array form using regular expression? Please share your ideas.
DOMDocument.preg_replaceusepreg_match_all