graham23s Posted February 6, 2010 Share Posted February 6, 2010 Hi Guys, Using this code: $regex_pattern = "/<a href=\"(.*)\">(.*)<\/a>/"; preg_match_all($regex_pattern,$result,$matches); $i = 0; foreach($matches as $match) { print $match[0]; } I gather all the "a href" anchor tags on page, but my foreach only outputs the first one and doesn't loop them all? plus the first say 5 anchor tags i don't really need is there a way to start looping from say the 5th one onwards? thanks guys Graham Quote Link to comment Share on other sites More sharing options...
RussellReal Posted February 6, 2010 Share Posted February 6, 2010 there is if you use strpos and substr instead of regex You can also use strpos and preg_match_all together with preg_match's offset argument. Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted February 6, 2010 Share Posted February 6, 2010 I would recommend using the DOM over both methods to be honest http://www.jaygilford.com/php/php-dom-get-all-pagelinks/ 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.