gmcust3 Posted January 8, 2011 Share Posted January 8, 2011 <?php ini_set('display_errors',true);//Just in case we get some errors, let us know.... // create a new cURL resource $ch = curl_init(); $fp = fopen (dirname(__FILE__) . '/a.txt', 'w+');//This is the file where we save the information // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://www.whitepages.com.au/resSearch.do?subscriberName=smith&givenName=&location=Melbourne+VIC"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); $file = fopen("a.txt", "r") or exit("Unable to open file!"); while(!feof($file)) { $regex="/clearfix\"><h1 class(.*)</h1></div><div class/"; echo preg_replace($regex,"",fgets($file)); } fclose($file); // close cURL resource, and free up system resources curl_close($ch); ?> I am getting the Error as Warning: preg_replace() [function.preg-replace]: Unknown modifier 'h' in /var/www/html/Leads/AUS/22.php on line 23 Any help why ? Quote Link to comment https://forums.phpfreaks.com/topic/223754-preg_replace-help-reqd/ Share on other sites More sharing options...
gmcust3 Posted January 8, 2011 Author Share Posted January 8, 2011 I am looking at http://www.phpro.org/examples/Get-Text-Between-Tags.html Quote Link to comment https://forums.phpfreaks.com/topic/223754-preg_replace-help-reqd/#findComment-1156588 Share on other sites More sharing options...
Pikachu2000 Posted January 8, 2011 Share Posted January 8, 2011 Your delimiter appears within your pattern. Either change your delimiter, or escape it where it appears in the pattern. $regex="~clearfix\"><h1 class(.*)</h1></div><div class~"; // OR $regex="/clearfix\"><h1 class(.*)<\/h1><\/div><div class/"; Quote Link to comment https://forums.phpfreaks.com/topic/223754-preg_replace-help-reqd/#findComment-1156637 Share on other sites More sharing options...
gmcust3 Posted January 8, 2011 Author Share Posted January 8, 2011 Tried But No Error, No Result. <?php ini_set('display_errors',true);//Just in case we get some errors, let us know.... // create a new cURL resource $ch = curl_init(); $fp = fopen (dirname(__FILE__) . '/a.txt', 'w+');//This is the file where we save the information // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://www.whitepages.com.au/resSearch.do?subscriberName=smith&givenName=&location=Melbourne+VIC"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); $file = fopen("a.txt", "r") or exit("Unable to open file!"); while(!feof($file)) { $regex="/clearfix\"><h1 class(.*)<\/h1><\/div><div class/"; preg_replace($regex,"",fgets($file)); } fclose($file); // close cURL resource, and free up system resources curl_close($ch); ?> Quote Link to comment https://forums.phpfreaks.com/topic/223754-preg_replace-help-reqd/#findComment-1156655 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.