Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts

    changing global text

    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

  • #2
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    PHP Code:
    $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.'/'.$fileimplode(''$phpfile));
        }

    PLEASE BACKUP YOUR FILES FIRST.

    Untested.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog

  • Users who have thanked Lamped for this post:

    durangod (12-01-2010)

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts
    thanks for that, ill test it out... beats doing this file by file manually..

  • #4
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    Quote Originally Posted by durangod View Post
    thanks for that, ill test it out... beats doing this file by file manually..
    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.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog

  • #5
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts
    omg tooo dang funny, im rollen lol but did the repairs include installing that missing usb port on your kettle...

  • #6
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    Quote Originally Posted by durangod View Post
    omg tooo dang funny, im rollen lol but did the repairs include installing that missing usb port on your kettle...
    USB port on the kettle...

    Hmm.

    Yeah, that would have been a good place to start.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •