/    Sign up×
Community /Pin to ProfileBookmark

keeping line breaks in text boxes

I am setting up a cms and was wondering if php had a function to keep the space of line breaks and spaces a user enters into a text area, so I could add paragraph breaks as they would choose.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@bokehJan 24.2006 — In a <textarea> that information will be passed to the server.
Copy linkTweet thisAlerts:
@marcato15authorJan 24.2006 — How can I change the space then into characters so I can store it in a database and keep the space.
Copy linkTweet thisAlerts:
@bokehJan 24.2006 — Maybe like this:[code=php]$field = preg_replace('/[r]?[n]/', '<br>', trim($_POST['field']));[/code]
Copy linkTweet thisAlerts:
@marcato15authorJan 25.2006 — It did work.
Copy linkTweet thisAlerts:
@NogDogJan 25.2006 — Also see the [url=http://www.php.net/nl2br]nl2br() function[/url].
×

Success!

Help @marcato15 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...