title: Inputting an array in a function pdo
body: <p>I'm trying to make a unified function for a PDO prepare UPDATE statement. But I am doing something wrong. Help would be very much appreciated.</p>
  
  <p>I'm passing an array and an email to a function:</p>
  
  <pre><code>function refreshUserData($items,$email)
  {
      global $pdo;
  
      $keys = array_keys($items);
      $keys = '('. implode(",", $keys) . ')';
  
      $values = array_values($items);
      $values = '(\''. implode("','", $values) . '\')';
  
      $query = $pdo-&gt;prepare("UPDATE users SET $keys VALUES $values WHERE email=?");
      $query-&gt;bindValue(1,$email);
      $query-&gt;execute();
  }
  </code></pre>
  
  <p>But I am doing something wrong because when I try to run a function <code>Uncaught exception</code></p>
  
  <p>This is my first attempt at doing this so don't know what to do.</p>
  
  <p>Array being passed through:</p>
  
  <pre><code>Array ( [google_id] =&gt; 11111111111111 [emal] =&gt; email@gmail.com [first_name] =&gt; First [last_name] =&gt; Last [profile_url] =&gt; https://plus.google.com/+FirstLast )
  </code></pre>
  
  <p>And after implodes:</p>
  
  <pre><code>(google_id,emal,first_name,last_name,profile_url)
  
  ('11111111111111','email@gmail.com','First','Last','https://plus.google.com/+FirstLast')
  </code></pre>