artisan Posted April 11, 2007 Share Posted April 11, 2007 Hey, i recently decided to code an extreamly simple php cms which i can use on any websites i make. so far i have made an input form, a procesing page, a flat file, and an index with an explode function which shows the last 5 posts newest to oldest. all of it works up to a point. the problem i have come accross is that when you fill in the message part of the form if you press enter to give a new paragraph it creates a new line on the flat file which the script then thinks is a new line of arrays which makes each new paragraph a new post adding it above its proper post... you can see my script work in progress here. www.xaoss.com/cms i wonder if its possible to somehow stop the line break in the textarea counting as one in the flatfile.... or even better if i can replace it with a < br> tag so it shows as a new paragraph. any help please? many thanks Link to comment https://forums.phpfreaks.com/topic/46619-can-anyone-help-me-with-this-please/ Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 www.php.net/nl2br That should get you what you want. Or to go to the paragraph tag: $data = str_replace("\n", '<p>', $data); Should also work. Link to comment https://forums.phpfreaks.com/topic/46619-can-anyone-help-me-with-this-please/#findComment-226987 Share on other sites More sharing options...
clown[NOR] Posted April 11, 2007 Share Posted April 11, 2007 where will the </p> be inserted? just a question Link to comment https://forums.phpfreaks.com/topic/46619-can-anyone-help-me-with-this-please/#findComment-226989 Share on other sites More sharing options...
sasa Posted April 11, 2007 Share Posted April 11, 2007 look nl2br() function Link to comment https://forums.phpfreaks.com/topic/46619-can-anyone-help-me-with-this-please/#findComment-226990 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 Unless you want to be "well-formed" html does not require a < /p> Something I learned along time ago. If you want to be well formed, this doubles the space but you can do < p>< /p> instead of just the < p> in the str_replace function. Link to comment https://forums.phpfreaks.com/topic/46619-can-anyone-help-me-with-this-please/#findComment-226993 Share on other sites More sharing options...
artisan Posted April 11, 2007 Author Share Posted April 11, 2007 thanks allot works perfectly . i think that will come usefull for other things too. Link to comment https://forums.phpfreaks.com/topic/46619-can-anyone-help-me-with-this-please/#findComment-226995 Share on other sites More sharing options...
clown[NOR] Posted April 11, 2007 Share Posted April 11, 2007 thanks for the lecture frost110... didn't know that Link to comment https://forums.phpfreaks.com/topic/46619-can-anyone-help-me-with-this-please/#findComment-227241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.