PHP Replace X with XX

Discussion in 'PHP' started by ChristopherLeeMaher.Com, Oct 30, 2010.

  1. #1
    Hello,

    On my site I have:
    <div style="visibility: visible; height: 250px;" class="alignR" id="google_companion_ad_div"></div>
    HTML:
    and want to replace it with:
    <a href="/here.php">Here</a>
    HTML:
    What is the PHP code I can use?

    Thank You
     
    ChristopherLeeMaher.Com, Oct 30, 2010 IP
  2. betaturn

    betaturn Peon

    Messages:
    273
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use:

    $actual='<div style="visibility: visible; height: 250px;" class="alignR" id="google_companion_ad_div"></div>';
    $after='<a href="/here.php">Here</a>';
    str_replace($actual,$after,$html4strict_code);

    Where: $html4strict_code is the code containing whole HTML code.
     
    betaturn, Oct 31, 2010 IP
  3. leh

    leh Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    But if it's on your site.. then why don't you just change the html? search and replace adds overhead.
     
    leh, Nov 1, 2010 IP