Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Сергей Шевченко
Added: Sep 4, 2018 9:26 AM
Modified: Sep 4, 2018 9:27 AM
Views: 0
Select one valid email from several
  1. /**
  2.  * @param string[] $emailList
  3.  * @return string
  4.  */
  5. function getValidEmail(string ...$emailList) : string {
  6.     foreach ($emailList as $email) {
  7.         if (filter_var($email, FILTER_VALIDATE_EMAIL)){
  8.             return $email;
  9.         }
  10.     }
  11.  
  12.     return '';
  13. }