使用explode插入2个数组到mysql表中

时间:2018-11-30 01:47:28

标签: mysql arrays explode

以下代码是错误的,有人知道如何编写正确的代码吗?

 foreach(explode('|',$btn) as $b)
    foreach(explode('|',$param) as $p)
      DB::insert("insert into commands (buttons, parameters) values (?, ?)", [$b, $p]);

我解决了:)

这里:

$b = explode('|', $btn);
$p = explode('|', $param);
$c = array_combine($b,$p);

foreach($c as $d => $key)
    DB::insert("insert into commands (buttons, parameters) values (?, ?)", [$d, $key]);

0 个答案:

没有答案