I searched the net for 2days looking for this answer. For what seems like a fairly easy solution i have been unable to come up with one.
I have a form that allows a user to enter an username or multiple user names separated by a comma. Out of that, i construct email addresses based on the users input.
The user would enter: mary,joe,sue and the result would produce
mary@domain.com
joe@domain.com
sue@domain.com
However, there is one restriction. The user many only separate each entry with a comma, no spaces allowed so if the user enters
mary, joe,sue then only
mary@domain would be accepted
and all other usernames would be rejected. This means i would need to spit the input based on "," and then check to see if any of the remaining entries have 1 or more spaces in front of them. If they do, i get out of the loop.
The problem is, how do i determine if there is one or more spaces in front of the arrray variable? I tried strpos but that did not work. I could not find any other solution.
Here is what i have so far;
$aliases = split("\,","$username");
foreach ($aliases as $alias)
{
Check $alias to see if it has one or more space in front of it. If it has, discard.
Anyone know what i can use? I dont want to trim it, simply reject.
Thanks