MattR Posted December 16, 2010 Share Posted December 16, 2010 Really cannot see why this doesn't work. $text = "<div id=\"page\"> <div class=\"item\"> Test </div> </div>"; preg_match("#<div id=\"page\"><div class=\"item\">(.*?)</div></div>#m", $text, &$match); var_dump($match); Output: array(0) { } Why?? Link to comment https://forums.phpfreaks.com/topic/221877-preg_match-to-find-div-content/ Share on other sites More sharing options...
mikecampbell Posted December 16, 2010 Share Posted December 16, 2010 You aren't matching the spaces/tabs/newlines that are between your nested div tags. Link to comment https://forums.phpfreaks.com/topic/221877-preg_match-to-find-div-content/#findComment-1148371 Share on other sites More sharing options...
requinix Posted December 16, 2010 Share Posted December 16, 2010 . will only match newlines (\r and \n) if you give the /s regex flag. Link to comment https://forums.phpfreaks.com/topic/221877-preg_match-to-find-div-content/#findComment-1148418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.