I am creating a tool to send emails and I want to allow for the option to write them in one line separated by a comma and space:
test@email.com, test2@email.com
OR multiple lines separated by a comma and space (which inadvertently creates more space):
test@email.com,
test2@email.com
The php code for the first option is easy:
$addresses = explode(', ', $this->data['emails']);
Which creates an array like this when you multi-line it:
array:1 [
0 => """
test@email.com,
test2@email.com
"""
]
Anyone know some simple logic/regex to allow for either? The first example of $this->data['emails']
comes as a string:
"test@email.com, test2@email.com"
And the second has the special characters to account for:
"""
test@email.com,
test2@email.com
"""