Hello,
I have a php array containing email addresses as array(email_address1 => name1, email2 => name2) format.
I need to check that emails are valid and I can foreach
and
foreach($arr as $email => $name) {
$new = array();
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
$new[$email] = $name;
}
return $new;
}
Can I achieve the above using array_filter? what would be the syntax??
array_filter($emails_arr, 'filter_var') ?? how about FILTER_VALIDATE_EMAIL parameter?
thanks.