/    Sign up×
Community /Pin to ProfileBookmark

set each line of textarea to element in an array

I am trying set each line submitted in a textarea to a seperate element in an array.

My attempts have been failing miserably so far.

any code or suggestions would be appreciated.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsOct 11.2004 — try this:[code=php]<?php
$array = preg_split("/r+n+/", $_POST['textarea'], NULL, PREG_SPLIT_NO_EMPTY);
?>[/code]
Copy linkTweet thisAlerts:
@NogDogOct 11.2004 — [i]Originally posted by ShrineDesigns [/i]

[B]try this:[code=php]<?php
$array = preg_split("/r+n+/", $_POST['textarea'], NULL, PREG_SPLIT_NO_EMPTY);
?>[/code]
[/B][/QUOTE]

I was thinking of essentially the same thing, but also trying to figure out how to handle the fact that I'm not sure which browser/OS combinations might send "rn", "n", or "r"; so I came up with:
[code=php]
$array = preg_split("/[rn]?[rn]/", $_POST['textarea'], -1, PREG_SPLIT_NO_EMPTY);
[/code]
Copy linkTweet thisAlerts:
@silent11authorOct 12.2004 — [i]Originally posted by NogDog [/i]

[B]I was thinking of essentially the same thing, but also trying to figure out how to handle the fact that I'm not sure which browser/OS combinations might send "rn", "n", or "r"; so I came up with:

[code=php]
$array = preg_split("/[rn]?[rn]/", $_POST['textarea'], -1, PREG_SPLIT_NO_EMPTY);
[/code]
[/B][/QUOTE]



That works great! Thanks.
×

Success!

Help @silent11 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.3,
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,
)...