Page 1 of 1
Replace underscores with spaces in txt file
Posted: Sun Dec 28, 2008 8:31 pm
by bugmenot
hi, I hardly have any PHP knowledge, so I would like someone to give me a code for this; I have a "text.txt" file on my server, which has underscores in it. I want a PHP code which replaces all the underscores with spaces and then save the txt. thanks

Re: Replace underscores with spaces in txt file
Posted: Sun Dec 28, 2008 8:36 pm
by requinix
bugmenot wrote:hi, I hardly have any PHP knowledge, so I would like someone to give me a code for this; I have a "text.txt" file on my server, which has underscores in it. I want a PHP code which replaces all the underscores with spaces and then save the txt. thanks

What have you tried? "Nothing" is not an acceptable answer.
Try using
file_get_contents to read the file,
str_replace to do the replacement, and
fopen/
fwrite/
fclose (PHP 4) or
file_put_contents (PHP 5) to write back to it.