CoreyR Posted June 23, 2007 Share Posted June 23, 2007 I have a text file which contains "&" and I'm trying to figure out how to replace the string with & and re-write the file. Any ideas or resources you know of would be appreciated. Corey R. Quote Link to comment Share on other sites More sharing options...
aim25 Posted June 24, 2007 Share Posted June 24, 2007 Use the str_replace function. Quote Link to comment Share on other sites More sharing options...
CoreyR Posted June 24, 2007 Author Share Posted June 24, 2007 What am I doing wrong here? $filename = "/htdocs/www/vmware/$username/index.php"; $fh = fopen($filename, 'r+') or die("can't open file"); foreach ($filename as $line) { str_replace("&", "&", $line); } $htmldata = $line_num; fwrite($fh, $htmldata); fclose($fh); Quote Link to comment Share on other sites More sharing options...
aim25 Posted June 24, 2007 Share Posted June 24, 2007 Im pretty sure that it's because $filename isnt a string. Quote Link to comment Share on other sites More sharing options...
aim25 Posted June 24, 2007 Share Posted June 24, 2007 Use file_get_contents, to make the file into a string. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.