title: PDO execute variable which stores array
body: <p>The $data variable stores an array containing a username and password, which need to be inserted in a certain table.</p>
  
  <pre><code>$data = array('username' =&gt; $username, 'password' =&gt; $password);
  foreach($data as $key =&gt; $value){
     $values = $values . "'" . $value . "'" . ",";
  }
  $sql = "INSERT INTO table(username, password) VALUES (?, ?)";
  $query = $con-&gt;prepare($sql);
  $query-&gt;execute($values);
  </code></pre>
  
  <p>How can I change this code in such a way that it will print the values of the $values variable into the execute function? E.g. 'Newuser','mysecretpass'</p>