I want to extract the href
of the anchor having only certain class with it like link-wrapper
.
So, this means I will have the href of the link like:
<a href="blaa..blaa" class="link-wrapper">click here</a>
P.S. It should extract both the links if they are aligned in sequential manner like:
<a href="blaa" class="link-wrapper">link-1</a><a href="blaa" class="link-wrapper">link-2</a>
I tried the solutions already present in the stack-overflow, but none suited my problem. Since some of them were in java-script and other languages. I tried looking for DOMDocument, but its bit difficult to exactly match the solution.
I tied some of the preg_match which didn't worked for me, like:
preg_match('/<a(?:(?!class\=")(?:.|\n))*class\="(?:(?!link\-wrapper)(?:.|\n))*link\-wrapper(?:(?!<\/a>)(?:.|\n))*<\/a>/i', $content, $output_array);