Hello I am saving email address from a textarea in a database. Now i want this data to be put in an array so I can send each email addres a mail.
On every line break there is an e-mail adres like so:
<textarea>
my@email.com
my2@email.com
my3@email.com
</textarea>
This data is save in the database as LONGTEXT. I get this data out of the database as a String.
But I want the data to be put in an array. So each email gets an unique index.
Note that no special characters like ‘\n’ and < br > are save in the database.
Thanks in advance!
Your question seems to indicate that you’re saving the email addresses in the textarea as whole rather than first splitting them up and saving each address separately. You will want to take the latter approach. Why split/validate everytime you read out of the database?
First, split the incoming emails with:
The regex allows you to take into account the different end of line characters the different platforms out there use.
Then you can loop over the addresses and validate each with:
Then save each address in its own row in the database.