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. 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. 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 Link to comment https://forums.phpfreaks.com/topic/262745-urgent-help-matching-contents/#findComment-1346683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.