pgrevents Posted April 25, 2009 Share Posted April 25, 2009 What I am trying to do is basicly (hopefully) is i am creating a bio part for my website and it will be saving to a mysql database. What I want to recreate is how the user typed it in such as spaces and line breaks like <br/> etc. If the user hits enter and creates a new paragraph in essence i want the php to add the <br/> I hope in reading this you understand what I am trying to get across cause I dont lol Does anyone have any ideas cheers Paul Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted April 25, 2009 Share Posted April 25, 2009 http://us.php.net/nl2br Quote Link to comment Share on other sites More sharing options...
pgrevents Posted April 25, 2009 Author Share Posted April 25, 2009 basicly the user will be entering into a normal text area form element and it recreates exactly what the user has typed??? Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted April 25, 2009 Share Posted April 25, 2009 That website goes over how to do exactly what you describe: <?php $formatted_submission = nl2br($unformatted_submission); ?> Quote Link to comment Share on other sites More sharing options...
pgrevents Posted April 26, 2009 Author Share Posted April 26, 2009 sorry for the delay what a simple solution lol thanks... now how would one remove the line breaks from showing in the text area for example updating the entered text? thanks again. Quote Link to comment Share on other sites More sharing options...
KPH71 Posted April 26, 2009 Share Posted April 26, 2009 <?php str_replace("<br>", "\n", $string); ?> Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 26, 2009 Share Posted April 26, 2009 sorry for the delay what a simple solution lol thanks... now how would one remove the line breaks from showing in the text area for example updating the entered text? thanks again. You should use nl2br when you display the text to screen. That way you wonthave to convert the <br /> tags with \n, which just over complicates things Quote Link to comment Share on other sites More sharing options...
pgrevents Posted April 26, 2009 Author Share Posted April 26, 2009 i never thought of that what i done was removed them using ereg_replace function but that sounds much better and probably more of a space saver in the long run. thanks Quote Link to comment 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.