GSMACK74 Posted August 30, 2008 Share Posted August 30, 2008 I got a peice of text returning from a database in this format: <tag>some dynamic text that changes</tag> followed by some other dynamic text. I'd like to remove everything within the tags returning only the text after the closing tag. any ideas? Link to comment https://forums.phpfreaks.com/topic/121955-string-parse-question/ Share on other sites More sharing options...
JasonLewis Posted August 30, 2008 Share Posted August 30, 2008 Regular Expressions? <?php $str = "<tag>some dynamic text that changes</tag> followed by some other dynamic text."; $str = preg_replace("#<.*?>(.*?)<\/.*?>#", "", $str); echo $str; ?> Link to comment https://forums.phpfreaks.com/topic/121955-string-parse-question/#findComment-629509 Share on other sites More sharing options...
DarkWater Posted August 30, 2008 Share Posted August 30, 2008 Either strip_tags() or: '/<([a-z]+)\b[^>]*>(.*?)<\/\\1>/i' As your regex. Link to comment https://forums.phpfreaks.com/topic/121955-string-parse-question/#findComment-629520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.