title: Insert multiple rows using single query
body: <p>I want to insert multipl rows in single query.  </p>
  
  <pre><code>$firstname = array('Arfan','Awais','Ahmad'.....);
  $lastname = array('Haider','k','Raza'..........);
  </code></pre>
  
  <p><strong>Insert Data:</strong></p>
  
  <pre><code>INSERT INTO `table_nmae`(firstname,lastname)
  VALUES
  ('Arfan','Haider'),('Awais','k'),('Ahmad','Raza');
  </code></pre>
  
  <p>I can do it very easily if these are only three record.<br>
  If I did not know how many records are present then I can not able to use the above.<br>
  Then what I did do?  </p>
  
  <p><strong>UPDATE:</strong><br>
  If I can not know the numbers of record in array.I can simply use <code>foreach loop</code> to do this
  But this decrease the performance.  </p>
  
  <pre><code>foreach($firstname as $f){
  foreach($lastname as $l){
     INSERT INTO `table_name`(firstname,lastname)
     VALUES('$f','$l');
  }
  
  }
  </code></pre>
  
  <p>Now this time I am using multi query.I think single query is good to performance.</p>
  
  <p><strong>FOR ONE COLUMN:</strong><br>
  If I had only one column it is very easy to use single query for this.  </p>
  
  <pre><code>INSERT INTO `table_name`(firstname) VALUES
  .implode(',', $firstname);
  </code></pre>
  
  <p>But here is multi column how can I do that for those.<br>
  Thanks.....</p>