N Nasimov New member Joined Mar 30, 2004 Messages 2 Location EarthPlanet Mar 30, 2004 #1 It's possible to ammend data within a file vs. just adding data to the beginning or the end of the file? Mean to change something in the "middle" of the file. Thanks.
It's possible to ammend data within a file vs. just adding data to the beginning or the end of the file? Mean to change something in the "middle" of the file. Thanks.
L l0rdphi1 Verified User Joined Jun 22, 2003 Messages 1,315 Mar 30, 2004 #2 Yes, you can, I'd do something like this: PHP: $s_fdat = file_get_contents('thefile'); $s_fdat = str_replace("search","replace",$s_fdat); $fp = fopen('thefile','w'); flock($fp,2); fwrite($fp,$s_fdat); fclose($fp);
Yes, you can, I'd do something like this: PHP: $s_fdat = file_get_contents('thefile'); $s_fdat = str_replace("search","replace",$s_fdat); $fp = fopen('thefile','w'); flock($fp,2); fwrite($fp,$s_fdat); fclose($fp);