【发布时间】:2014-07-04 04:30:37
【问题描述】:
PHP 中的代码是什么:
$string = '123,456,789,102'
$value = '564'
如何将$string拆分成一个数组,然后将数组中的每个值与$value拼接成一个二维数组,所以最终结果:
$result = (
(564,123),
(564, 456),
(564, 789),
(564, 102)
)
所以 $result 可以用于使用 PDO 在 mysql 中插入多行:
$stmt = $this->pdo->prepare('INSERT INTO tbl_user (id, bought) VALUES ((?,?),
(?,?),
(?,?),
(?,?),
(?,?),
)');
$stmt->execute($result);
注意:id 和购买的列是 varchar
【问题讨论】:
-
那么你尝试了这么少的代码?