Matthew du Plessis
Matthew du Plessis

Reputation: 307

How to seperate a list of items in php?

I have a list of 100 emails which I am trying to save to a database.

I can obtain the data in the page that it sends to via

the PHP $_POST variable but it stores all the data as one single item how do I separate this data so I can use it in a for loop on each item in the list so that I can save it into a database?

Upvotes: 0

Views: 34

Answers (1)

Brad Kent
Brad Kent

Reputation: 5097

Assuming that your emails are separated by a space or comma: you want the php function explode
and then foreach over the resulting array.

Or perhaps preg_split?
$emails = preg_split('/[\s;,]+/', $string_o_emails)

Upvotes: 2

Related Questions