Replace underscores with spaces in txt file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bugmenot
Forum Newbie
Posts: 23
Joined: Fri Oct 10, 2008 11:44 am

Replace underscores with spaces in txt file

Post 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 :oops:
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Replace underscores with spaces in txt file

Post 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 :oops:
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.
Post Reply