Replace underscores with spaces in txt file
Moderator: General Moderators
Replace underscores with spaces in txt file
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
What have you tried? "Nothing" is not an acceptable answer.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
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.