Jump to content

Multiple str_replace in php script not working.


RyanFox

Recommended Posts

Hello,

 

I have multiple str_replace with file_put_contents in my script and it only seems to run the last str_replace.

 

If I remove the last one it runs the first one fine.

 

Code:

 

$file_name = "txt.txt";
$contents = file_get_contents($file_name);
 
//first
$updom = str_replace("google.com",$domain,$contents); 
file_put_contents($file_name, $updom);
 
//last
$upip = str_replace("74.125.226.110",$ip,$contents); 
file_put_contents($file_name, $upip);
 
google.com and that ip are just for testing.
 
If I run that the ip one works but not the domain one, if I comment out the IP one the domain one works fine...
 
What is going on?
 
Thanks,
Ryan

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.