title: array_keys() expects parameter 1 to be array
body: <p>I am using angular as the front end and php at the backend.</p>
  
  <p>I am trying to post some data as array from angular to php and get the error <code>array_keys() expects parameter 1 to be array</code> in console.</p>
  
  <p><strong>angular.js</strong></p>
  
  <pre><code>var form_data_head = {};
  form_data_head['doc_no'] = $scope.add.doc_no;
  form_data_head['date'] = $scope.add.tanggal;
  form_data_head['requisitor'] = $scope.add.requisitor;
  
  $http({
    method: 'POST',
    url: "api/config/function-insert.php",
    data: {
      form_data_head: form_data_head,
      tablename: 'pr_head',
    },
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    }
  }).then(function(response){
    console.log(response.data);
  }, function(response){
    console.log("failed");
  })
  </code></pre>
  
  <p><strong>php</strong></p>
  
  <pre><code>&lt;?php
  
  require_once 'db.php';
  
  $postdata = file_get_contents('php://input');
  $request = json_decode($postdata);
  
  $table_name = $request-&gt;tablename;
  $form_data_head = $request-&gt;form_data_head;
  
  $fields = array_keys($form_data_head);
  
  $sql = "INSERT INTO ".$table_name." (`".implode('`,`', $fields)."`) VALUES('".implode("','", $form_data_head)."')";
  return $mysqli-&gt;query($sql);
  ?&gt;
  </code></pre>
  
  <p>is it wrong way to pass the array from angular to php?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>this is what i get from the console if i add <code>var_dump($request-&gt;form_data_head);</code></p>
  
  <pre><code>object(stdClass)#3 (3) {
    ["doc_no"]=&gt;
    string(4) "test"
    ["date"]=&gt;
    string(24) "2016-05-10T04:26:02.857Z"
    ["requisitor"]=&gt;
    string(0) ""
  }
  </code></pre>