I have a form with 5 sets of inputs. An email and a key. I am creating an array for each set, then looping through them to send an email.
In some cases, not all 5 set of fields will be filled in. In my testing, this still sends a blank email. So I think I need to first create an array of each set of inputs, loop through them and then exclude the array or arrays that's empty?
Here is my current code, any help with an explanation so I can learn would be amazing!
if(isset($_POST['submit'])) {
$donors = array_map(null, $_POST['email'], $_POST['key']);
foreach( $donors as $donor) {
// Mail script will go here.
}
}
Would I use another isset, or empty? And how?