...

View Full Version : changing global text



durangod
12-01-2010, 05:46 PM
hi i have a documentation comment header at the top of my php files and i changed my forum url and rather than manually open each of my files and change the url text, can i use php fopen to do so globally, whats the best path to follow here ? thanks..

example is /* for support www.xxx.com */

and i need to change it to for support www.yyy.com

Lamped
12-01-2010, 06:00 PM
$folder = scandir('folder with files to change');
foreach($folder as $file) {
if (is_file($folder.'/'.$file) && (substr($file, -4) == '.php')) { // saves bothering with . and .. checks too
$phpfile = file($folder.'/'.$file); // should include line breaks
$phpfile[0] = str_replace('www.xxx.com', 'www.yyy.com', $phpfile[0]);
file_put_contents($folder.'/'.$file, implode('', $phpfile));
}
}

PLEASE BACKUP YOUR FILES FIRST.

Untested.

durangod
12-01-2010, 06:03 PM
thanks for that, ill test it out... beats doing this file by file manually.. :thumbsup:

Lamped
12-01-2010, 06:05 PM
thanks for that, ill test it out... beats doing this file by file manually.. :thumbsup:

Yeah, I have a personal motto: Never do it twice if a script can do it for you.

Unfortunately, last time I tried hooking the kettle up to the USB port it cost me a lot of money in repairs.

durangod
12-01-2010, 06:51 PM
omg tooo dang funny, im rollen lol but did the repairs include installing that missing usb port on your kettle... :p:)

Lamped
12-01-2010, 06:53 PM
omg tooo dang funny, im rollen lol but did the repairs include installing that missing usb port on your kettle... :p:)

USB port on the kettle...

Hmm.

Yeah, that would have been a good place to start.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum