我正在尝试内爆一个数组来执行插入,但我无法触发我所做的错误。 implode() [function.implode]: 传递的参数无效 *请注意我的数组大小不固定,所以我使用了 foreach*
数组结构
[attcode] => Array ( [0] => [1] => [2] => )
[color] => Array ( [0] => [1] => [2] => )
[size] => Array ( [0] => [1] => [2] => )
[stock] => Array ( [0] => [1] => [2] => )
工作代码
$attstring = array();//array for storing query set
foreach($productcount['attcode'] as $attcode){
$attstring[] = "'" . implode("','", $attcode)."'";
}
foreach($productcount['color'] as $attcolor){
$attstring[] = "'" . implode("','", $attcolor)."'";
}
foreach($productcount['size'] as $attsize){
$attstring[] = "'" . implode("','", $attsize)."'";
}
foreach($productcount['stock'] as $attstock){
$attstring[] = "'" . implode("','", $attstock) . "'";
}
$finalvalue = "(" . implode("), (", $attstring) . ")";
echo $finalvalue;
期望的输出
('code','color','size',stock),
('code','color','size',stock),
('code','color','size',stock)