title: PHP: How to keep NULL when imploding array
body: <p>In my insert method of my database class I pass the parameters as an array:</p>
  
  <pre><code>$sql='INSERT INTO `'.$table.'` (`'.implode('`, `',array_keys($params)).'`) VALUES ("' . implode('", "', $params) . '")';
  </code></pre>
  
  <p>As you can see, the array gets imploded.</p>
  
  <p>My <code>$params</code> for example looks like this:</p>
  
  <pre><code>$params = [
    'field1' =&gt; 'sometext1',
    'field2' =&gt; 'sometext2',
    'stamp_created' =&gt; NULL
  ]
  </code></pre>
  
  <p>My field <code>'stamp_created'</code> must be set NULL, so that the date of creation gets displayed in the data row in the database. However, imploding the array turns <code>NULL</code> to an empty string <code>""</code>:</p>
  
  <pre><code>VALUES ('sometext1', 'sometext2', '')
  </code></pre>
  
  <p>How do I achieve that <code>NULL</code> does not get ignored in my implode operation? My desired result is:</p>
  
  <pre><code>VALUES ('sometext1', 'sometext2', NULL)
  </code></pre>