Jump to content

PREG_REPLACE NIGHTMARE


mocapoke

Recommended Posts

Why is this preg_replace emptying the string rather than replacing it...

$string = file_get_contents("http://mocapoke.com/blogReader/select_list.html");
 $pattern = "<option value='$filetitle'>$y</option>";
 $newscon = preg_replace($pattern,"",$string);
echo $newscon;

Even if I enter a string to replace it with, the string is still empty... for example:

 

If I change the code to this:

$string = file_get_contents("http://mocapoke.com/blogReader/select_list.html");
 $pattern = "<option value='$filetitle'>$y</option>";
 $newscon = preg_replace($pattern,"REPLACED",$string);
echo $newscon;

 

REPLACED won't be printed.

 

Link to comment
https://forums.phpfreaks.com/topic/48996-preg_replace-nightmare/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.