fork download
  1. <?php
  2. $subject = "<a href=\"http://w...content-available-to-author-only...n.com/main/1,1,51,463-Here_Goes_A_Name.aspx?shmod=1\" class=\"srTtl2a\">Here is the name</a><a href=\"http://w...content-available-to-author-only...n.com/main/1,1,51,463-Here_Goes_A_Name.aspx?shmod=1\" class=\"srTtl2a\">Here is the name</a><a href=\"http://w...content-available-to-author-only...n.com/main/1,1,51,463-Here_Goes_A_Name.aspx?shmod=1\" class=\"srTtl2a\">sdasdas</a>";
  3. $pattern = '/\<a\shref=\"(.+?)\"\s.+?\>(.+?)\<\/a\>/';
  4.  
  5. preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER);
  6. //print_r($matches);
  7.  
  8. foreach ($matches as $match) {
  9. echo "Url: " . $match[1] . "\n";
  10. echo "Path: " . parse_url($match[1], PHP_URL_PATH) . "\n";
  11. echo "Title: " . $match[2] . "\n\n";
  12. }
  13. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Url: http://w...content-available-to-author-only...n.com/main/1,1,51,463-Here_Goes_A_Name.aspx?shmod=1
Path: /main/1,1,51,463-Here_Goes_A_Name.aspx
Title: Here is the name

Url: http://w...content-available-to-author-only...n.com/main/1,1,51,463-Here_Goes_A_Name.aspx?shmod=1
Path: /main/1,1,51,463-Here_Goes_A_Name.aspx
Title: Here is the name

Url: http://w...content-available-to-author-only...n.com/main/1,1,51,463-Here_Goes_A_Name.aspx?shmod=1
Path: /main/1,1,51,463-Here_Goes_A_Name.aspx
Title: sdasdas