colap Posted December 4, 2011 Share Posted December 4, 2011 User can post anything. After a line user can hit enter and can start a new sentence. I wan to replace the newline character ('\n') to html '<br/>' element. I need to output a break in html page. How can i do this with php ? How can i check whether a string contains '\n' or not ? Which function can i use for that ? Quote Link to comment https://forums.phpfreaks.com/topic/252447-how-can-i-replace-all-n-to-from-a-post/ Share on other sites More sharing options...
Drongo_III Posted December 4, 2011 Share Posted December 4, 2011 Hi Mate you could try this $teststring = "This is a new string \n and i just out a line in"; echo nl2br($teststring); It replaces all new lines with html line breaks Quote Link to comment https://forums.phpfreaks.com/topic/252447-how-can-i-replace-all-n-to-from-a-post/#findComment-1294311 Share on other sites More sharing options...
colap Posted December 4, 2011 Author Share Posted December 4, 2011 Hi Mate you could try this $teststring = "This is a new string \n and i just out a line in"; echo nl2br($teststring); It replaces all new lines with html line breaks How can i check whether a string contains '\n' or not ? Quote Link to comment https://forums.phpfreaks.com/topic/252447-how-can-i-replace-all-n-to-from-a-post/#findComment-1294319 Share on other sites More sharing options...
Pikachu2000 Posted December 4, 2011 Share Posted December 4, 2011 strpos Quote Link to comment https://forums.phpfreaks.com/topic/252447-how-can-i-replace-all-n-to-from-a-post/#findComment-1294323 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.