php实现插入数组到mysql数据库的函数,代码如下:
<?php /** * 保存数组数据到mysql * by www.jb200.com */ public function insertData($table,$data){ $field=implode(',', array_keys($data)); foreach (array_values($data) as $key=>$val){ $value .="'".$val."'"; if ($key<count($data)-1) $value .=","; } $sql= "INSERT INTO ".$table."(".$field.") values(".$value.")"; return $this->insert($sql); } ?>