Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8847451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:11:36+00:00 2026-06-14T12:11:36+00:00

I help manage a nonprofit website with a large number of html files, probably

  • 0

I help manage a nonprofit website with a large number of html files, probably around 1,000. Broken links are a hassle, and I was wondering if it would be possible, perhaps with PHP, to create a program that replaces a text string (ie a URL) across all of these files.

Would it create a lot of server strain with this many files?
What about if, say 10 people, were simultaneously using the program to find and replace across all 1,000 files?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:11:37+00:00Added an answer on June 14, 2026 at 12:11 pm

    It certainly is possible!

    The key to this is to be able to read a file in PHP, and to process its contents. Reading is dead-easy, so is writing. Editing is the bit that’ll require your attention.

    $yourFilename = "file.html";
    $yourFileData = file_get_contents($yourFilename);
    if ($yourFileData !== false) {
         // File has been read successfully
         // $yourFileData has the contents of it. This is where the magic needs to happen!
    }
    // Write everything back
    $file = fopen($yourFilename,"w");
    fwrite($file,$yourFileData);
    fclose($file);
    

    This snippet of code effectively reads a file, and writes a file. The bit in the middle is where you’ll do your search-and-replace. I strongly recommend using regular expressions for this. preg_replace will come in very handy for this, I am sure. Read up on it, and feel free to edit your question with more details – I’m more than happy to write the regular expressions for you.

    Iterating through a directory is also pretty straightforward. You want to open a directory using opendir() and loop through using readdir(), making sure that the return value is not ., .. or false, and is a file.

    For your additional question re:multiple users, I’d avoid if I were you. This creates race conditions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are looking to use GIT to help manage our web files as we
I'm trying to build a project to help users manage their S3 account. To
I need help understanding how to manage the API for an iPhone application that
Thanks in advance for any help you can provide on this issue! I manage
I am in desperate need of help, I need to manage an application dependency
I'm looking for a Python IDE that can help me easily locate and manage
Does anyone have any tips or best practices regarding how Autofac can help manage
I've been using Git Flow to help manage branch and workflow. I love how
Is there anything built into MassTransit that can help manage the queues? I'm specifically
First let me say, I am not a coder but I help manage a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.