I want to replace each character in file with another one by one "walk" through the file.
It is like using fgetc(), but I also need to replace that char. My file is big, which is the best way to do this? Any advice?
I want to replace each character in file with another one by one "walk" through the file.
It is like using fgetc(), but I also need to replace that char. My file is big, which is the best way to do this? Any advice?
If you're a Linux user look into the use of sed
. There are alternatives for windows that allow you to do it as well but you'll need to download them (they're not default)
It works like this: say you have a sentence "Hello World". Run the command:
sed s/l/p/g sentence.txt
You get the output: "Heppo Worpd" (replacing all l's with p's).
fopen mode c+ should do what you want. See http://www.php.net/manual/en/function.fopen.php