Finwyn Posted March 16, 2007 Share Posted March 16, 2007 I want to be able to go though source from a website and grab what is between all the <li></li> and <a href="lalala"></a> . I am new to regex and was wondering if its possible to do this with it? Link to comment https://forums.phpfreaks.com/topic/42960-grabbing-infomation-between-tags/ Share on other sites More sharing options...
effigy Posted March 16, 2007 Share Posted March 16, 2007 Does it need to work recursively, e.g., finding a's in li's? <pre> <?php $html = <<<HTML ... <a href="http://www.phpfreaks.com">www.phpfreaks.com</a> <ul> <li>Item 1</li> <li>Item 2</li> <li><a href="#Item_3">Item 3</a></li> </ul> ... HTML; preg_match_all('%<(a|li).*?>(.+?)</\1>%', $html, $matches); print_r($matches); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/42960-grabbing-infomation-between-tags/#findComment-208758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.