I need to open a file , replace some content( 12345 with 77348) and save it. As far I have
$cookie_file_path=$path."/cookies/shipping-cookie".$unique; $handle = fopen($cookie_file_path, "r+"); $cookie_file_path = str_replace("12345", "77348", $cookie_file_path);
fclose($handle);
However it doesn’t seem to work …. I would appreciate any help!
Nowhere in your code do you access the content of your file. If you are using PHP 5, you can use something like the following:
If you are on PHP 4, you will need to use a combination of fopen(), fwrite(), and fclose() in order to get the same effect as file_put_contents(). However, this should give you a good start.