keeps21 Posted September 7, 2009 Share Posted September 7, 2009 As per the title. I need to remove the text between the first <h1></h1> tags in the input string - but leave any further <h1></h1> tags in the string as they are. Any help would be appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/173392-remove-text-between-first-tags-of-input-string/ Share on other sites More sharing options...
thebadbad Posted September 7, 2009 Share Posted September 7, 2009 preg_replace() has a limit parameter: $str = preg_replace('~<h1>.*?</h1>~is', '<h1></h1>', $str, 1); Link to comment https://forums.phpfreaks.com/topic/173392-remove-text-between-first-tags-of-input-string/#findComment-914050 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.