Is there an efficient way to split a string containing a list of email addresses into groups of say 50? Say I have a string that contains emails in a comma-separated format. Something like… email1@host.com,email2@host.com,email3@host.com and so on.
The most obvious way to do this would probably be an array, but is there a way to do it with string functions? I have looked at substr and str_split and they don’t quite seem to do the job.
It should be by far more efficient to search for the 50th occurrence of a comma and split the string after this.
So find this Position. I think this http://www.php.net/manual/en/function.strpos.php#102336 should be a solution for that.
Then split the string with substr and remove the comma at pos 1 of the new string.
Shortened PHP-Code to fit your needs: