tp assign 能传递二维数组吗
1个回答
展开全部
$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);
}
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);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询