Skip to content

Instantly share code, notes, and snippets.

@mithereal
Created June 29, 2015 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mithereal/6f5c98168688e6c7dbb2 to your computer and use it in GitHub Desktop.
Save mithereal/6f5c98168688e6c7dbb2 to your computer and use it in GitHub Desktop.
arraytosql
<?php
function arrayToSql($array=array(),$pre='',$post='',$xor='&&')
{
$end = end(array_keys($array));
$sql = $pre;
foreach($array as $k =>$v){
$sql .= "`$k` = '$v' ";
if($k != $end){
$sql .= "$xor ";
}
}
$sql = $post
return $sql;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment