The error s basically telling me that my $user_names is not a array, I have checked all the spelling and watch the video 3 times, if anyone could help be I would sincirely appreciated.
here is my code
if(isset($_POST['to'], $_POST['subject'], $_POST['body'])){
$errors = array();
if(empty($_POST['to'])){
$errors[]= 'Necesitas añadir un destinatario';
}else if(preg_match('#^[a-z, ]+$#', $_POST['to']) === 0){
$errors[]= 'La lista de nombres que has introducido no es correcta.';
}else{
$user_names= explode(',', $_POST['to']);
foreach($user_names as &$name){
$name= trim($name);
}
$user_ids = fetch_user_ids($user_names);
if(count($user_ids)!== count($user_names)){
$errors[]= 'Los siguientes usuarios no han sido encontrados: '. implode(', ', array_diff($user_names, array_keys($user_ids)));
}
}
Thank you