Jump to content

STR Replace Used To Delete Everything Between 2 Tags


Brandon_R

Recommended Posts

Hello members of this forum. I am trying to use str_replace to delete everything between 2 tags. (<!-- open tag --> AND <!-- / open tag -->. Between the tags are some code and i would like to use str_replace to remove the code.

 

For example

 

<!-- open tag --> <a href="http://www.phpfreaks.com>PHP Freaks</a> <!-- / open tag -->

 

What would be the PHP code to turn the above code to nothing (' '). I was thinking a regular expression, if so i may have to post this in the regex forum.

 

 

Thank you

 

Brandon_R


$stuff = '<!-- open tag --> <a href="http://www.phpfreaks.com>PHP Freaks</a> <!-- / open tag -->';

$no_stuff = explode( "<a href="http://www.phpfreaks.com>PHP Freaks</a>", $stuff);
echo $no_stuff[0] . $no_stuff[2];

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.