onlyican Posted November 19, 2010 Share Posted November 19, 2010 Hi, I have a string which contains a mix of Content and anchor links Example: //Example $strContent = 'I am some <a href="/content.htm">Content</a> here, but I could have <a href="/link.php">a Link</a> <a href="http://www.example.com">Followed by another</a> Link, Mix external and not.'; I basically want to programatically pull out all of the Anchor links, and have an array of such Array('/content.htm', '/link.php', 'http://www.example.com'); Help me please. Got a brain freeze as its Friday Afternoon Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted November 19, 2010 Share Posted November 19, 2010 preg_match_all Quote Link to comment Share on other sites More sharing options...
sasa Posted November 19, 2010 Share Posted November 19, 2010 <?php $strContent = 'I am some <a href="/content.htm">Content</a> here, but I could have <a href="/link.php">a Link</a> <a href="http://www.example.com">Followed by another</a> Link, Mix external and not.'; preg_match_all('~href=("|\')(.*?)\1~', $strContent, $out); print_r($out[2]); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.