如何为每个循环php存储来自两个数组的备用值

I have created two arrays and i want to add there alternate values in a database table

foreach($aaa[$key] as $key2 and $bbb[$key] as $key3) {
  $qd = "INSERT INTO aaa (xxx, yyy, status) VALUES ('$key2', '$key3', '1')";
  $dd = mysqli_query($conn, $qd);
  if ($dd) {
    echo '1';
  } else {
    echo mysqli_error($conn);
  }
}

So you wanted to have 2 loops for your arrays that will be both used on your query. You use indexes instead in your loop.

// count of items. from what you wanted to do to your loop
// it looks like it is given that the count of 2 arrays are
// the same.
$count = count($aaa[$key]);

for ($i = 0; $i < $count; $i++) {
    $qd = "INSERT INTO aaa (xxx, yyy, status) VALUES ($aaa[$key][$i], $bbb[$key][$i], '1')";
    $dd = mysqli_query($conn, $qd);

    if ($dd) {
        echo '1';
    } else {
        echo mysqli_error($conn);
    }
}