gibigbig Posted May 18, 2012 Share Posted May 18, 2012 Hey, I need a bit of help replacing some variables in a string. I know its done with preg_replace. Here is the string: Header 1 <|header 2|> header 3 <b>header 4</b> I would like to get ONLY <|header 2|> from the above string. But "header 2" is variable so please its useless if the preg_replace isn't flexible to find whatever word is in there regardless. Thanks you. Quote Link to comment https://forums.phpfreaks.com/topic/262745-urgent-help-matching-contents/ Share on other sites More sharing options...
premiso Posted May 18, 2012 Share Posted May 18, 2012 $string = preg_replace('#<|.*?|>#', $replacement, $string); Something like that should suffice. Quote Link to comment https://forums.phpfreaks.com/topic/262745-urgent-help-matching-contents/#findComment-1346682 Share on other sites More sharing options...
gibigbig Posted May 18, 2012 Author Share Posted May 18, 2012 ^^ thank you Quote Link to comment https://forums.phpfreaks.com/topic/262745-urgent-help-matching-contents/#findComment-1346683 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.