- var_dump: documentation ( source)
- preg_match: documentation ( source)
<?php
$string = "<!-- static comment-->
<a href='/dir1/dir2/DYNAMIC'>
STRING1
STRING2
</a>";
$pattern ="#<a.*?>\s*\n*.*?(\w+)\s*\n*.*?(\w+)#s";
preg_match($pattern, $string, $match);
var_dump($match);