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! Quote 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. Quote 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); Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/98312-preg_replace/#findComment-503070 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.