Im taking data from a form and e-mailing it using wp_mail
, since there is multiple data (all check box data) there obviously needs to be a foreach.
I cannot wrap my head around getting the data inside the foreach and using it outside the statement.
//My form data
$checks = $_POST['personalization_result'];
//Pass the foreach array into this variable and use this to mail
$checkString = '';
//For each checkbox data
foreach ($checks as $k => $v) {
var_dump ($v);
}
//Email the data
$sent = wp_mail($to, $subject, $checkString, $headers); //I have set up the other variables but its not necessary to add here just focused on $checkString
Snippet of the form
<form action="<?php the_permalink(); ?>" method="post">
<?php echo $checkString; ?>// Trying to see what the array is doing
<input type="hidden" name="submitted" value="1">
<p><input type="submit"></p>
<li class="option table selected">
<input type="hidden" value="0" name="personalization_result[memory_0]">
<input type="checkbox" value="1" name="personalization_result[memory_0]" id="personalization_result_memory_0" checked="checked">
</li>
<li class="option table selected">
<input type="hidden" value="0" name="personalization_result[memory_1]">
<input type="checkbox" value="1" name="personalization_result[memory_1]" id="personalization_result_memory_1" checked="checked">
</li>
Im sorry if this is a bit noobish, but this is how I learn by asking.