3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "ukahfranklin@yahoo.com, abhishek.b@contecglobal.com, Ukah Franklin B , <<option1>>, <<<option2>>>, Okechukwu Second name\n Abuja Airport, abvairport@contecglobal.com, <<<this option2>>>\n accounts.abuja@contecglobal.com, Accounts Abuja \n dejiashiru@contecglobal.com, Adeji Ashiru "; $result=array(); $no=0; $var = explode("\n",$string); foreach($var as $v){ $w = preg_split('/[,;]/',$v); foreach($w as $l){ if(preg_match('/((?<option2>(<{3}.+>{3}))|(?<option1>(<{2}.+>{2}))|(?<email>([a-zA-Z0-9.!#$%&?+\/=?^_`{|}~-]+@{1}[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{2,}){1,11}))|(?<name>([^<>@]{2,10}[\w\W])+))/', $l, $matches)){ if(!empty($matches['option2'])){$result[$no]['option2']=$matches['option2'];} if(!empty($matches['option1'])){$result[$no]['option1']=$matches['option1'];} if(!empty($matches['email'])){ $result[$no]['email']=$matches['email']; }elseif(!empty($matches['name'])){ $result[$no]['name']=$matches['name']; } } } $no++; } print("<pre>".print_r($result,true)."</pre>"); exit();

preferences:
55.86 ms | 402 KiB | 5 Q