I have a variable within PHP coming from a form that contains email addresses all separated by a comma (') For example: [email protected],[email protected],[email protected],[email protected]
What I am trying to achieve is to look at the variable, find for example @domain2.com and remove everything between the comma that are either side of that email.
I know I can use str_replace to replace just the text I'm after, like so:
$emails=str_replace("@domain2.com", "", "$emailscomma");
However, I'm more looking to remove that entire email based on the text I'm asking it to find.
So in this example I'm wanting to remove [email protected] and [email protected]
Is this possible?
Searched any articles I could find but couldn't find something that finds something and then replaces but more than just the text it finds.
preg_replace.