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 Link to comment https://forums.phpfreaks.com/topic/191135-regex-html/ 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. Link to comment https://forums.phpfreaks.com/topic/191135-regex-html/#findComment-1007850 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/ Link to comment https://forums.phpfreaks.com/topic/191135-regex-html/#findComment-1007854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.