remove some text from a string..

Discussion in 'PHP' started by redhits, Sep 16, 2009.

  1. #1
    If i am having a text like bla bla bla bla

    then
    <--MakyFancy Ad code here-->
    BLA BLA BLA here is random code

    <--End of MakyFancy Ad code-->

    How i can remove everything that is inside the Maky Fancy breakers, including that MakyFancy ad code

    I hope you get me
     
    redhits, Sep 16, 2009 IP
  2. Digital Linx

    Digital Linx Peon

    Messages:
    74
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
  3. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #3
    Try:
    <?php
    $string = "1<--MakyFancy Ad code here-->BLA BLA BLA here is random code<--End of MakyFancy Ad code-->1";
    
    $string = preg_replace("/<--MakyFancy Ad code here-->.*<--End of MakyFancy Ad code-->/","HEllO",$string);
    
    echo $string;
    
    ?>
    PHP:
    OUTPUT:1HEllO1
     
    dweebsonduty, Sep 16, 2009 IP