Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Writting to multipule files  RSS feed

 
Gary Goldsmith
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, firstly a little description of my situation! I've started a new job this week, a web design job, and most of the week the corporate site of the company is undergoing change and as a newbe! I get the nice job of changing the code in lots of php files, these files all have the same text in them but need to be changed. So all I'm doing is copying and pasting the new code into these php files, the new code is the same for all these files.
This is REALLY boring so I want to make my job faster, I want to write a program that gets all the files in a directory (php only!) and changes the information in the files. I've done a similar program before but you have to declare the file name first and the output file name:

example:



So what I need to do now is work out how to read in x amount of php files and write the new php code into each file. Can anyone help me?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can you identify the part of the file that needs to be replaced - is it a particular string?
 
Gary Goldsmith
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The entire file needs to be changed.
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you solving a PHP-problem with java-code?

You can write your standaard text in one php-file and use a PHP-include in al the other php-pages.

For help on the php-include have a look at

PHP include

This is a more decent solution.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!