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; Quote 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 Quote 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 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/263786-problems-with-using-nl2br/#findComment-1351804 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.