fork download
  1. <?php
  2.  
  3. $emails = array(
  4. 'foo@bar.com',
  5. 'null@void.com',
  6. 'invalid string'
  7. );
  8.  
  9. $emails = implode(', ', array_filter($emails, 'MYFILTERS_emails'));
  10. echo $emails;
  11.  
  12. //------
  13.  
  14. function MYFILTERS_emails($val){
  15. return !!(filter_var($val, FILTER_VALIDATE_EMAIL));
  16. }
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
foo@bar.com, null@void.com