d_barszczak Posted June 28, 2007 Share Posted June 28, 2007 Hi all, I am developing a simple seach engine script that puts words found in a html document into a table notes the url and the occourances. What i would like it to do is find any hyperlinks that are in the html document and im not sure how to pick out the hyperlinks and place them in an array. Quote Link to comment Share on other sites More sharing options...
effigy Posted June 28, 2007 Share Posted June 28, 2007 <pre> <?php $html = <<<HTML <ul> <li><a href="http://www.google.com">Google</a></li> <li><a href="http://www.letspolka.com">Let's Polka</a></li> <li><a href='http://www.neatorama.com'>Neatorama</a></li> <li><a href=http://www.phpfreaks.com>PHP Freaks</a></li> </ul> HTML; preg_match_all('/(?<=href=)[\'"]?([^\s"\'>]+)/', $html, $matches); array_shift($matches); print_r($matches); ?> </pre> Quote Link to comment Share on other sites More sharing options...
d_barszczak Posted July 27, 2007 Author Share Posted July 27, 2007 Thank you, I like to try do things myself first but i have been scratching my head for weeks now. Kinda gutted you answered is so quickly. Thanks Again. 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.