Saturday, 10 August 2013

php code for modifing text file

php code for modifing text file

I am trying to modify text file with PHP but my code is not working. Here
is my php code to modify the content of text file.
<?php
$file = "results.txt";
$fh = fopen($file,'w+');
while(!feof($fh))
{
$array = explode("\n", file_get_contents($file));
$contents = $array[0];
$new_contents = str_replace($contents,"1234", $array);
}
file_put_contents($file, $new_contents);
fclose($fh);
?>

No comments:

Post a Comment