/    Sign up×
Community /Pin to ProfileBookmark

A br2nl function

Hi,

Can someone please post here a function/ regular expression supporting converting <br> tags to new line characters.

That means inverse of nl2br().

Thanks and Best Regards

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@SrWebDeveloperAug 24.2009 — Hi,

Can someone please post here a function/ regular expression supporting converting <br> tags to new line characters.

That means inverse of nl2br().

Thanks and Best Regards[/quote]



[code=php]function br2nl($string)
{
return preg_replace('/<br(s*)?/?>/i', "n", $string);
}[/code]
note: the replacement string is followed by n for a newlines char.

-jim
Copy linkTweet thisAlerts:
@NogDogAug 24.2009 — Functionally the same as above, just removing a few key-strokes. ?
[code=php]
return preg_replace('#<brs*?/?>#i', "n", $string);
[/code]
×

Success!

Help @GUIR 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.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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