editing a file with PHP

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
frankm
Forum Newbie
Posts: 1
Joined: Mon May 12, 2008 6:01 pm

editing a file with PHP

Post by frankm »

Hello. I need PHP to edit a text file. For example.

I have a text file with the following contents:

Code: Select all

$color1 = red
$color2 = blue
$color3 = green
$color4 = orange
How would I have a PHP script go and edit color3 to yellow?

Thanks!
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: editing a file with PHP

Post by califdon »

frankm wrote:Hello. I need PHP to edit a text file. For example.

I have a text file with the following contents:

Code: Select all

$color1 = red
$color2 = blue
$color3 = green
$color4 = orange
How would I have a PHP script go and edit color3 to yellow?

Thanks!
Check out http://w3schools.com/php/php_ref_filesystem.asp
Post Reply