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. Quote 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); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.