Schlo_50 Posted March 28, 2008 Share Posted March 28, 2008 Hey guys, If i have the sentence: "A long time ago[break]a bear walked[break]in the woods." How would I use preg_replace to change the '[break]' parts into '<br />' ? I don't understand the php.net example. Thanks! Link to comment https://forums.phpfreaks.com/topic/98312-preg_replace/ Share on other sites More sharing options...
conker87 Posted March 28, 2008 Share Posted March 28, 2008 str_replace("[break]", "/r/n", $string); I think. Link to comment https://forums.phpfreaks.com/topic/98312-preg_replace/#findComment-503057 Share on other sites More sharing options...
wildteen88 Posted March 28, 2008 Share Posted March 28, 2008 str_replace("[break]", "/r/n", $string); I think. OP wants a html line break not a newline. str_replace("[break]", "<br />", $string); Link to comment https://forums.phpfreaks.com/topic/98312-preg_replace/#findComment-503064 Share on other sites More sharing options...
conker87 Posted March 28, 2008 Share Posted March 28, 2008 Note to self: read tags too! /facepalm. Link to comment https://forums.phpfreaks.com/topic/98312-preg_replace/#findComment-503070 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.