email users using array from foreach
<p>i asked a previous question about his but it has changed since, i would like to create an array from the db query '$to' and use it in the <code>email_to_user()</code> function. This will hopefully email all users from the <code>$entry-&gt;dept</code> array.</p>

<p>when $entry->dept = 1 this works and emails the user from department #1
when $entry->dept = 1,30 the email function fails</p>

<pre><code>$divisions = explode(",", $entry-&gt;dept);

foreach($divisions as $division) {
    $divs=get_record('induction_emails','id',$division);
    $useremail = get_record('user', 'email', $divs-&gt;email);
    $to = get_record('user', 'id', $useremail-&gt;id);
}

if (email_to_user($to, $from, $subject, $body)){


redirect('thanks.php');
die;

} 
else {
}
?&gt;
</code></pre>

<p>Cheers for any help, much appreciated.</p>
