Once your web site grows beyond a dozen or so pages, updating all of the web pages when you change your web page template can become a big job. What is most annoying, especially if you have hundreds of web pages on your site is that most if not all of the pages will require exactly the same changes to be made to them.
Wouldn't it be easier if you could set up the required changes and apply them in bulk to all of the pages on your site? Well if your site supports PHP then you can easily use that to perform the bulk updates for you.
The first step is to copy the content of the text area below and save it to the directory where you want to make the changes using the name change.php.
The search and replace arrays at the top of the script need to be updated to specify the updates that you want to perform. Each of the strings of characters you want to find go into the search array as regular expressions and the strings of characters that you want to replace them with (as plain text) go into the corresponding entries in the replace array.
When you bring up the change.php page in your web browser the bulk update function will run. For each file within the same directory (with the exception of itself (and the temp.out file that it uses as a temporary output) it will read in the file, make the requested changes, and save the file as temp.out. If any changes were applied then the temp.out file will then be copied back over the original file (this avoids authority problems over ownership of the files).
Once the page finishes displaying the list of what files have been checked then you can delete the change.php file from the site. Of course you will probably want to keep a copy of it somewhere for the next time you need to make bulk updates.
This article written by Stephen Chapman, Felgall Pty Ltd.