thinkphp 二维数组怎么插入数据库
$data = array(
216 => array(
'a' => 1,
'b' => 3456,
'c' => '广州天河',
'd' => 98765
),
217 => array(
'a' => 1,
'b' => 3456,
'c' => '广州天河',
'd' => 98765
),
218 => array(
'a' => 1,
'b' => 3456,
'c' => '广州天河',
'd' => 98765
),
219 => array(
'a' => 1,
'b' => 3456,
'c' => '广州天河',
'd' => 98765
)
);
foreach ($data as $k => $v) { // 循环保存每一条值
$map = array();
$map['k'] = $k; // 保存216 这个键名
$map['a'] = $v['a'];
$map['b'] = $v['b'];
$map['c'] = $v['c'];
$map['d'] = $v['d'];
M('')->table('table_name')->add($map);
}