You want to distinguish the emails according to the groups. According to your question, 12345678
and 12345
are groups.
what you can do is explode the email two times. One time with @
and second time with .
. Let me show you how you can do this.
$email_exploded = explode('@',$email) // this will give you ['someone.12345','something.in']
Now, You can further explode first part of the $email_exploded
array with .
and get the last part of the array. It will be your group. Just like this…
$email_array = explode('.',$email_exploded);
$group = end($email_array);
$group
will be the group of each and every email. If you have an array of emails, you can run foreach
loop and and make multi-dimensional array including email with its group. Let me know if it helps. Let me know if you have any more questions.
solved Distinguish between two emails using php