I want to curl a page and extract data between a div tag <div class="topmasters" align="center"> data required </div> here is my code // create a new curl resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://example.com/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // grab URL, and return output $output = curl_exec($ch); // close curl resource, and free up system resources curl_close($ch); preg_match_all('/<div\s class=\'topmasters\' \s align=\'center\'>(.*?)<\/div>/",$output, $t); $output=str_replace('/<div\s class=\'topmasters\' \s align=\'center\'>','',$t[0]); echo $output; ?> Code (markup): Please help to spot the error in the code?
preg_match_all('/<div\s class=\'topmasters\' \s align=\'center\'>(.*?)<\/div>/",$output, $t); Starts with a single quote, ends with a double for starters... Add error_reporting(E_ALL); to your code I would also not bother with the \s unless you're sure they're needed. Dan