gamesmad
-
Posts
14 -
Joined
-
Last visited
Never
Posts posted by gamesmad
-
-
Is it possible to replace a whole line, regardless of content, with str_replace?? If not, what could I use instead??
Will -
I cannot thank you enough :) I have finally got my script finished :P
Thanks,
Will -
How would I use fread to find part of it, and replace it with something else??
Will -
OK, I just whipped up this -
[code]<?php
require "config.php";
$settingscontents = file_get_contents("$boarddir/$account/Settings.php", "r+");
echo "$settingscontents";
?>[/code]
Where do I go from here, fread() seems to only look through a file by bytes?? I want to find some text in the file and replace it with something else.
Will -
OK thanks guys, I will produce some of mine code, and Ill come back if it doesnt work.
Will -
So using fopen will bind the contents of the file to the variable?? I dont understand what fread does, something to do with reading the filesize?? I understand fwrite. Hope you can answer.
Thanks,
Will -
Hey,
Does anyone have any working code that will allow me to open a file, find part of it, replace that part with something else, and then save the file??
Thanks,
Will -
I still cant get it to work, please can someone help??
Will -
Now the file doesnt get edited... And other ideas nogray, or anyone else??
Will -
OK, I had a go with str_replace, now there is no error, but it doesnt work. I have attached the file.
Will
[attachment deleted by admin] -
I get the error -
[code]Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /home/gamesm/public_html/freeforums/suspend.php on line 26[/code]
Lines 21 - 26 go like this -
[code]21 $settingscontent = file_get_contents($settingsdir);
22
23 $mode[0] = "$maintenance = 0;";
24 $newmode[0] = "$maintenance = 2;";
25
26 $newsettingscontent = preg_replace($mode, $newmode, $settingscontent);[/code]
Any idea where I am going wrong?? Its stopping my script from working...
Will -
Thanks very much, your a legend :)
Will -
What is the command for finding and replacing part of a file? Hope you guys can help.
Thanks,
Will
Modifying a file with PHP
in PHP Coding Help
Posted
Will