On Wednesday 13 July 2011 11:09:45 Jay Ess wrote: > On 2011-07-13 09:54, Karl DeSaulniers wrote: > > $cc = "ema...@domain.com ,ema...@doamin.com,ema...@domain.com , > > ema...@domain.com, " > > $cc = trim($cc,","); > $result = preg_replace('/(\s?)(,)(\s?)/i', ',', $cc);
The solution is broken because of: 1) you have missed spaces after comma in two places. It should be like this: $cc = trim($cc,", "); // <- here space after comma in the second argument $result = preg_replace('/(\s?)(,)(\s?)/i', ', ', $cc); // <-- the same, here space after comma in replacement string. 2) it doesn't work with address lines like this: To: "Some strange ,, person name" <strper...@example.com> -- Vitalii -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php