/    Sign up×
Community /Pin to ProfileBookmark

Help with selecting multiple values out of a text input field.

I have a simple internal messaging system set up and I want the users to have the ability to enter multiple recipients in the “To” field, separated by a comma or semicolon.

I’m either searching the wrong terms or have the wrong idea of how this is done. Any suggested links or other resources are appreciated ?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiJul 06.2010 — [code=php]$recipients = preg_split('/,|;/', $_POST['to'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($recipients as $recipient) {
echo "sending to $recipient<br />";
}
[/code]
Copy linkTweet thisAlerts:
@NogDogJul 06.2010 — I like to have it trim any white-space while it's at it:
[code=php]
$recipients = preg_split('/s*[,;]s*/', trim($_POST['to']), -1, PREG_SPLIT_NO_EMPTY);
[/code]
Copy linkTweet thisAlerts:
@jefepwnzerauthorJul 07.2010 — Got it and working, thanks for the help!
×

Success!

Help @jefepwnzer 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.26,
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,
)...