Hi All,
I have this part of script which is ‘getting’ values via a form $_POST (in a foreach loop) :
foreach($_POST['user'] as $key => $username) {
foreach($_POST['add_user_to_task'][$key] as $check => $checked){
$task_name = $_POST['task_name'][$key][$check];
if ($checked == 1) {
} // end if CHECKED == 1
else {
}
} // end foreach 2
} // end foreach 1
Everything is fine, except when the user doesn’t check ANY checkbox. Then I get the warning
Warning: Invalid argument supplied for foreach() in /path_to_file/ajax/ajaxupload.php on line 14
which is just logic, cause the loop doesn’t get the value for the key (it was NOT checked by the user)
line 14 :
foreach($_POST['add_user_to_task'][$key] as $check => $checked)
I can turn off warning messages by I really want the script to be clean. Now how can I ‘tell’ the second foreach NOT to run if there’s no checked add_user_to_task[$i] value? Any help is appreciated! Regards