Reputation: 2293
I have some email formats like
[email protected] - Admin,[email protected] - Kika,[email protected] - Mka,
I need to send the email in php for multiple id's now due to above name its sees to error
Expected output
[email protected],[email protected],[email protected],
I need to remove the name after the all mail id how can i do that i have tried str_replace
but thats not gives me a solution.
How can i use preg_match
in this case ?
Upvotes: 0
Views: 72
Reputation: 1374
Reg Exp
$list = '[email protected] - Admin,[email protected] - Kika,[email protected] - Mka,';
$str = preg_replace('/'.preg_quote('-') .'.*?'.preg_quote(',') . '/', ',', $list);
Rtrim To remove the end comma
$str = rtrim($str, ',');
Upvotes: 1