hoangthi Posted April 4, 2012 Share Posted April 4, 2012 This is source of a page: http://vn-ace.com/forum/test.txt I want to get contents betweent <blockquote class="postcontent restore"> and </blockquote> but i dont know how to do ? How can i do ? Please help me. I am newbie. Thanks Quote Link to comment Share on other sites More sharing options...
scootstah Posted April 4, 2012 Share Posted April 4, 2012 Something like: $source = file_get_contents('test.txt'); $pattern = '/<blockquote class="postcontent restore">(.*?)<\/blockquote>/'; preg_match_all($pattern, $source, $matches); Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted April 4, 2012 Share Posted April 4, 2012 scootstah, I don't think your code will work, because it doesn't support multiline This supports multiline: $source = file_get_contents('test.txt'); $pattern = '/<blockquote class="postcontent restore">(.*)<\/blockquote>/isU'; preg_match_all($pattern, $source, $matches); print_r($matches); Quote Link to comment Share on other sites More sharing options...
hoangthi Posted April 5, 2012 Author Share Posted April 5, 2012 so, what should i do ? Quote Link to comment Share on other sites More sharing options...
hoangthi Posted April 5, 2012 Author Share Posted April 5, 2012 how can i get each element of $matches Ex: $matches[1], $matches[2]... Quote Link to comment Share on other sites More sharing options...
scootstah Posted April 5, 2012 Share Posted April 5, 2012 With a foreach loop. 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.