Shadowing Posted June 6, 2012 Share Posted June 6, 2012 Hey guys im having a issue getting nl2br to work When im retrieving text from mysql it works fine but its not working just in a php variable. test test test test $test = "test\n\ntest\n\ntest\n\ntest"; $test = nl2br($test ); echo $test; Link to comment https://forums.phpfreaks.com/topic/263786-problems-with-using-nl2br/ Share on other sites More sharing options...
Shadowing Posted June 6, 2012 Author Share Posted June 6, 2012 ehh i just tested that example i made and it works. so something else is wrong hmm im returning it using echo json_encode(array("display" => $test)); Then using jquery to html replace it into a div Link to comment https://forums.phpfreaks.com/topic/263786-problems-with-using-nl2br/#findComment-1351767 Share on other sites More sharing options...
Shadowing Posted June 7, 2012 Author Share Posted June 7, 2012 wierd json_encode is adding the \n back in Link to comment https://forums.phpfreaks.com/topic/263786-problems-with-using-nl2br/#findComment-1351771 Share on other sites More sharing options...
Shadowing Posted June 7, 2012 Author Share Posted June 7, 2012 Figure out was causing it. was using mysql_real_escape_string before returning it Link to comment https://forums.phpfreaks.com/topic/263786-problems-with-using-nl2br/#findComment-1351804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.