title: Can i use Multiple Array in a foreach loop?
body: <p>I have researched several related question in this forum and google, Kindly assist . I am trying to insert some values into database from several arrays stored in session. I also have some single values stored in some session also which i want to insert into multiple rows of dbase table. </p>
  
  <p>//First, I recall the values stored in sessions from previous pages into the current page as below.</p>
  
  <p>//take note of the comment in front of the sessions and All array contains the same number of values except for the first two sessions. </p>
  
  <pre><code>$ticketid="t".date('dmyHis').mt_rand (1000,9999);
          $bettime= date('d/m/y H:i');
          $_SESSION['bettime']=$bettime;//Not array, contains single value
          $_SESSION['ticketid']=$ticketid;//Not array, Contains single value
          $_SESSION['gamecode'];//array
          $_SESSION['starttime'];//array
          $_SESSION['optioncode']//array
          $_SESSION['home'];//array
          $_SESSION['away'];//array
          $_SESSION['odd'];//array
  </code></pre>
  
  <p>Here, I connected to dbase. //Works fine.
  require('gumodb.php');</p>
  
  <p>Here i try to start a loop using one array session as key</p>
  
  <pre><code> foreach($_SESSION['starttime'] as $ro =&gt; $col){
      mysql_query("INSERT INTO reg_bet (bettime, ticketid,matchcode,starttime,home,away,optionodd,optioncode) VALUES('$_SESSION[bettime]','$_SESSION[ticketid]','$_SESSION[gamecode]', '$_SESSION[starttime]','$_SESSION[home]','$_SESSION[away]','$_SESSION[odd]','$_SESSION[optioncode]' ) ") 
      or die(mysql_error());  
  
              }
  </code></pre>
  
  <p>It returns Notice: Array to string conversion in C:\xampp\htdocs\gumo\consel.php on line 61</p>
  
  <p><strong>EDIT QUESTION</strong>
  I am trying to achieve something like this.</p>
  
  <pre><code>foreach($_SESSION['gamecode'] as $gc =&gt; $gcvalue &amp;&amp; $_SESSION['starttime'] as $st =&gt;$stvalue &amp;&amp; $_SESSION['optioncode'] as $oc =&gt; $ocvalue ){ 
  mysql_query("INSERT INTO reg_bet (matchcode,starttime,optioncode) VALUES('$gcvalue','$stvalue','$ocvalue') ") 
  or die(mysql_error());  }
  </code></pre>