Lets say I have two arrays –
$EmailList1 = array("abc@domain1.com", "def@domain2.com", "ghi@domain3.com");
$EmailList2 = array("jkl@domain1.com", "mno@domain4.com", "pqr@domain5.com");
Now I’d like my new array to be [mno@domain4.com, pqr@domain5.com]
The reason jkl@domain1.com was omitted because it has domain (domain1.com) which already is present in $EmailList1
My approach would be to first get all the domains of $EmailList1, storing it into an array, looping through each item of $EmailList2 and then getting the result.
Is this the right way or there could be a better way ?
All you need is
Output