CodilX Posted June 18, 2006 Share Posted June 18, 2006 Hi again :)Now I'm having trouble extracting a portion of content out of page. Basicly it looks like this:[code]some content....<img src="someimage.jpg">multiple lines of content that I want to extract...<div id="something">.. some content[/code]I'm trying to do it with [b]if (stristr($text, "<img src="someimage.jpg">")) {[/b] .. but with no luck :(Can somebody help me with this?Thx - Matt Link to comment https://forums.phpfreaks.com/topic/12288-content-extraction/ Share on other sites More sharing options...
poirot Posted June 18, 2006 Share Posted June 18, 2006 You may want to use regex:[code]preg_match('/<img src="someimage.jpg">(.*?)<div id="something">/', $string, $matches);echo '<pre>';print_r($matches);echo '</pre>';[/code] Link to comment https://forums.phpfreaks.com/topic/12288-content-extraction/#findComment-46976 Share on other sites More sharing options...
CodilX Posted June 18, 2006 Author Share Posted June 18, 2006 [!--quoteo(post=385295:date=Jun 18 2006, 05:27 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 18 2006, 05:27 PM) [snapback]385295[/snapback][/div][div class=\'quotemain\'][!--quotec--]You may want to use regex:[code]preg_match('/<img src="someimage.jpg">(.*?)<div id="something">/', $string, $matches);echo '<pre>';print_r($matches);echo '</pre>';[/code][/quote]Thx alot, but it doesn't go with my code. Could you write that with the connection to the site?I get an error:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: preg_match() [function.preg-match]: Unknown modifier 't' in ...*.php on line 5Array()[/quote] Link to comment https://forums.phpfreaks.com/topic/12288-content-extraction/#findComment-46984 Share on other sites More sharing options...
CodilX Posted June 19, 2006 Author Share Posted June 19, 2006 *bump* Link to comment https://forums.phpfreaks.com/topic/12288-content-extraction/#findComment-47226 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.