Right. Im trying to use preg_match_all() to get some strings: the source file is here: http://www.ps3peak.com/src.txt Code (markup): and the code im using to get this is: $source= file_get_contents("src.txt"); preg_match_all("/<span class=\"postbody\">(.*)<\/span>/mi", $cource, $posts); print_r($posts[1]); PHP: but i only get 3 results when i should get 4 Ive used the "m" modifier as the source is multiline.... any clues?
Try adding the "U" flag to the im modifiers - it makes the expression ungreedy so that it will match the smallest chunk of text that it can rather than the largest, which is the default. It could be matching one from one <span> to the second </span> rather than the first which is what you want cheers johnt
Try: preg_match_all("/<span class=\"postbody\">(.*)<\/span>/simU", $source, $posts); Code (markup): Should work with your newlines.
another option is to lose the newlines altogether (if you don't need them) before doing the preg_match_all $source = str_replace ("\n", ' ', $source); $source = str_replace ("\r", ' ', $source); PHP:
yeah did that in the end Bloody hosting copany deleted my forum so i had to rebuild it from the google cache!!
>> Bloody hosting copany deleted my forum so i had to rebuild it from the google cache!! Hope you have a new hosting company now