Skip to content

Instantly share code, notes, and snippets.

@hanafiah
Created October 24, 2013 08:11
Show Gist options
  • Save hanafiah/7133140 to your computer and use it in GitHub Desktop.
Save hanafiah/7133140 to your computer and use it in GitHub Desktop.
<?php
//Answer #2
preg_match_all('/<a(?:\s+(?:href=[\'"](?P<href>.*?)[\'"]|title=[\'"](?P<title>.*?)["\']|\w+=[\'"](?P<other_attribute_goes_here>.*?)[\'"]))+/', $str, $match,PREG_PATTERN_ORDER);
print_r(array('href'=>$match['href'],'title'=>$match['title']));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment