galvin Posted February 13, 2010 Share Posted February 13, 2010 I have a textarea in a form where I input multiple email addresses and I separate them by a comma and then I use the following code to send an email to all of the addresses... if(!empty($_POST['sendemails'])){ $_emails=explode(",",$_POST['sendemails']); foreach($_emails as $v){ $bcc .= $v . ', '; // note the comma } Works fine, but I want to be able to separate them by comma OR semicolon OR a space/return. How can I alter the code to look for any of those three, rather than just looking for a comma? Link to comment https://forums.phpfreaks.com/topic/191935-how-to-explode-multiple-characters/ Share on other sites More sharing options...
premiso Posted February 13, 2010 Share Posted February 13, 2010 If you use the preg_split function it can do regex matching. I am not 100% sure but this should work: $_emails=preg_split("([, ;\n])", $_POST['sendemails']); Link to comment https://forums.phpfreaks.com/topic/191935-how-to-explode-multiple-characters/#findComment-1011644 Share on other sites More sharing options...
galvin Posted February 13, 2010 Author Share Posted February 13, 2010 Works like an absolute charm! Thanks so much! Link to comment https://forums.phpfreaks.com/topic/191935-how-to-explode-multiple-characters/#findComment-1011646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.