array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

array

Post by pinehead18 »

Help me out here guys.

I have a list of users i select with check boxes.
I want to create an array that houses all the users name.

Then i use swift to send an email to all those users emails one at a time.

Help making the array?

Thanks
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

That's at least two questions.

Your form field should use an array structured name, e.g.

Code: Select all

<input type="checkbox" name="username[]" value="Jim" />Jim
<input type="checkbox" name="username[]" value="John" />John
...and so on.

The second part is retrieving that data as an array, which in this case (assuming you're using a POST method form, which you should be) will be accessible via $_POST['username'], in this case an array stored within that $_POST index.

Once you receive the POST data, use a foreach() loop on the $_POST['username'] array and send the email to those users, one per iteration.
Post Reply