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 3937146
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:02:07+00:00 2026-05-20T00:02:07+00:00

I have a php page which contains a large amount of HTML in it.

  • 0

I have a php page which contains a large amount of HTML in it. One part of the HTML has a div in the following format:

<div class="reusable-block" id="xyzabcwy">there is a lot of HTML here which may be in any format</div>

Keep in mind, this div is contained within the DOM at any location however, I do know the div ID programatically.

I was originally finding this string within my database, since a record of it exists there however, the format between the data in the database record and the page are sometimes different due to whitespace but other than the white space, the strings are exactly the same. The problem is, I don’t know what format the whitespace is in.

It seems it is better to write a regular expression to find this div and replace it entirely.
I could use a hand though.

Other ideas are also welcome.
Many thanks!

  • 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-05-20T00:02:07+00:00Added an answer on May 20, 2026 at 12:02 am

    If you are using jQuery,

    $('#xyzabcwy').html(new_data);
    

    if not

    document.getElementById('xyzabcwy').innerHTML = new_data;
    

    otherwise, here is a PHP example.

    Edit: PHP

    <?php
     $id = "xyzabcwy";
     $html = "<div id=\"" . $id . "\">this is html</div>";
     $newdata = "test";
     echo preg_replace("#<div[^>]*id=\"{$id}\".*?</div>#si",$newdata,$html);
    ?>
    

     This should output

    <div id="123">test</div>
    

    Answer from: Replace a div content with PHP

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

Sidebar

Related Questions

I have a html page ( editor.php ) which contains a lot of html
I have a php file which contains only one class. how can I know
I have a php page which contains a form. Sometimes this page is submitted
lets say i have two pages links.html & contents.php ... first page contains only
I have a php page which contains keys and salts and I would like
I have a PHP-generated page which is displaying some data about a set of
I have a main page which contains a simple iframe. Iframe source = a
I have an Array in PHP which contains data from database. And it prints
i have table question (mysql with php) which contains question,category(multiple) and subcat(multiple) its belong.
I have a script in PHP which removes empty paragraphs from an HTML file.

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.