获取具有2个或更多条件的foreach循环的值

I am trying to insert multiple record from my HTML form to my Database Using PHP i just learn that it is possible to have foreach loop with 2 or more condition now my problem is how can i get those value and insert it to my database? here is my sample code:

 while($p = mysqli_fetch_assoc($qry)){
   // this loop has more than 1 data to fetch
 ?>
   <input type="hidden" name="studName[]" value="">
   <input type="hidden" name="studId[]" value="">
   <input type="" name="text1[]" value="">
 <?php
 }

Now getting each value from this textbox array, here is my code:

 foreach (array($text1, $studName, $studId) as $data) {
  //qry for inserting value from array in one table
 }

you can use the variable this way. (if all arrays are the same size).

foreach($text1 as $key => $text){
   echo $text1[$key];
   echo $studName[$key];
   echo $studId[$key];
}