I have the following code. I am trying to get everything inside the "a" tags. At the moment it is working. I am getting “first” and “second” as an output. opening "a" tag and closing "a" tag are in the same line.
$v = 'this is test
<a href="products.html">first</a>
<a>second</a;
preg_match_all("#<a\b[^>]*>(.*?)</a>#", $v, $foo);
echo implode("\n", $foo[1]);
But if I write the following way,
$v = '<a href="products.html">first
</a>
preg_match_all("#<a\b[^>]*>(.*?)</a>#", $v, $foo);
echo implode("\n", $foo[1])';
here i moved the closing "a" tag to the second line and now It's not giving me any output. Does anyone know how to make it work?