title: How to dynamically add array values into string?
body: <p>I have array with db col names.</p>
  
  <pre><code>$db_cols = ['name', 'age', 'gender'];
  </code></pre>
  
  <p>I need to add POST values into db query from array <code>$db_cols</code> dynamically. Result must be something like this.</p>
  
  <pre><code>$db-&gt;query('INSERT INTO tbl (id, '.implode(', ', $db_cols).', order) VALUES (?, '.str_repeat('?, ', count($db_cols)).' ?)', [$_POST['id'],$_POST['name'], $_POST['age'], $_POST['gender'], $order]);
  </code></pre>
  
  <p>But I need modify this part of the code above <code>$_POST['name'], $_POST['age'], $_POST['gender']</code></p>
  
  <p>Query result:</p>
  
  <pre><code>INSERT INTO tbl (id, name, age, gender, order) VALUES (?, ?, ?, ?, ?),[1, 'Joe', '35', 'male', 1]
  </code></pre>
  
  <p>Thank you for help.</p>