Guardian-Mage Posted September 15, 2007 Share Posted September 15, 2007 Ok, I have a php file, I need to open it, find the line that reads "$pass[0] = "fa03eb688ad8aa1db593d33dabd89bad";" and edit the value "fa03eb688ad8aa1db593d33dabd89bad". How can I do that, I have #Open the file $ourFileName = "access.php"; $fh = fopen($ourFileName, 'r+') or die("Can't open file"); fclose($fh); Quote Link to comment https://forums.phpfreaks.com/topic/69515-editing-a-line-in-a-file/ Share on other sites More sharing options...
rarebit Posted September 15, 2007 Share Posted September 15, 2007 You could try 'preg_replace()', ref http://uk3.php.net/manual/en/function.preg-replace.php... say $filename = "/usr/local/something.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); $contents = preg_replace("fa03eb688ad8aa1db593d33dabd89bad", "new_hash", $contents); // resave file Quote Link to comment https://forums.phpfreaks.com/topic/69515-editing-a-line-in-a-file/#findComment-349297 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.