Brandon_R Posted August 3, 2009 Share Posted August 3, 2009 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 Link to comment https://forums.phpfreaks.com/topic/168616-str-replace-used-to-delete-everything-between-2-tags/ Share on other sites More sharing options...
Brandon_R Posted August 3, 2009 Author Share Posted August 3, 2009 I meant preg_replace. Sorry guys. Link to comment https://forums.phpfreaks.com/topic/168616-str-replace-used-to-delete-everything-between-2-tags/#findComment-889455 Share on other sites More sharing options...
dreamwest Posted August 3, 2009 Share Posted August 3, 2009 $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]; Link to comment https://forums.phpfreaks.com/topic/168616-str-replace-used-to-delete-everything-between-2-tags/#findComment-889510 Share on other sites More sharing options...
Brandon_R Posted August 3, 2009 Author Share Posted August 3, 2009 Thank you for your responce but i was kinda looking for a reg ex (accidently posted in the wrong forum so ill repost thread there) that would match anything between 2 tags. Link to comment https://forums.phpfreaks.com/topic/168616-str-replace-used-to-delete-everything-between-2-tags/#findComment-889799 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.