title: PHP Implode Associative Array
body: <p>So I'm trying to create a function that generates a SQL query string based on a multi dimensional array. </p>
  
  <p>Example:</p>
  
  <pre><code>function createQueryString($arrayToSelect, $table, $conditionalArray) {
  $queryStr = "SELECT ".implode(", ", $arrayToSelect)." FROM ".$table." WHERE ";
  $queryStr = $queryStr.implode(" AND ",$conditionalArray); /*NEED HELP HERE*/
  return $queryStr;
  }
  
  $columnsToSelect = array('ID','username');
  $table = 'table';
  $conditions = array('lastname'=&gt;'doe','zipcode'=&gt;'12345');
  echo createQueryString($columnsToSelect, $table, $conditions); /*will result in incorrect SQL syntax*/
  </code></pre>
  
  <p>as you can see I need help with the 3rd line as it's currently printing</p>
  
  <blockquote>
    <p>SELECT ID, username FROM table WHERE
    lastname AND zipcode</p>
  </blockquote>
  
  <p>but it should be printing</p>
  
  <blockquote>
    <p>SELECT ID, username FROM table WHERE
    lastname = 'doe' AND zipcode = '12345'</p>
  </blockquote>