I have a weird problem with array_combine() function. In fact, I've got two arrays of the same length ($skills and $skills_level), the first array contains checked checkboxes from a html form, and second one contains associated options. I'd like to iterate them simultaneously and insert their elements in a DB table:
foreach(array_combine($skills, $skills_level) as $skill => $skill_level) {
$insert_skills = "INSERT INTO worker_skills(worker_username, skill, level) VALUES('$worker_username', '$skill', '$skill_level')";
$query1 = mysqli_query($conn, $insert_skills);
It all goes well apart from one particular value, which is the first checkbox of the form. I'm pretty sure it goes into the $skills array (I tested it), but for some reason it's not being inserted into table row, neither it is its associated value from array $skills_level. I tried different methods (getting array keys separately, using a for loop, etc.) but the problem persists. Can anyone help me with that?