suttercain Posted April 27, 2007 Share Posted April 27, 2007 I understand this: <?php $string = "John Doe \n Mary Doe \n Steven Doe \n"; echo $string; // echoes John Doe Mary Doe Steven Doe echo nl2br($string); echoes John Doe Mary Doe Steven Doe ?> My question is this: Is it possible to have the results looks as they did in echo nl2br($string); without using the nl2br or the <br> tag? Just curious. SC Link to comment https://forums.phpfreaks.com/topic/48988-for-my-own-curiousity-nl2br/ Share on other sites More sharing options...
jchemie Posted April 27, 2007 Share Posted April 27, 2007 str_replace("\n","<br />", str_replace("\r","<br /",str_replace("\n\r", "<br /",$string))); Remember the changing of order is going to change functionallity. in anycase you shouldnt use \n\r outside. Thanks Jyot Link to comment https://forums.phpfreaks.com/topic/48988-for-my-own-curiousity-nl2br/#findComment-239997 Share on other sites More sharing options...
effigy Posted April 27, 2007 Share Posted April 27, 2007 pre tags? Link to comment https://forums.phpfreaks.com/topic/48988-for-my-own-curiousity-nl2br/#findComment-240003 Share on other sites More sharing options...
suttercain Posted April 27, 2007 Author Share Posted April 27, 2007 pre tags? For some reason it took out the break tag < br > Link to comment https://forums.phpfreaks.com/topic/48988-for-my-own-curiousity-nl2br/#findComment-240033 Share on other sites More sharing options...
effigy Posted April 27, 2007 Share Posted April 27, 2007 I don't follow... <pre> <?php echo $string = "John Doe \n Mary Doe \n Steven Doe \n"; ?> </pre> Yields: John Doe Mary Doe Steven Doe Link to comment https://forums.phpfreaks.com/topic/48988-for-my-own-curiousity-nl2br/#findComment-240036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.