0

我通过 POST 表单得到以下数字:1,2,3 | 3,4,5 但我只想选择之前的数字 | 并一一插入到mysql表中,怎么做?

4

2 回答 2

1
$str = '1,2,3 | 3,4,5';
$data = trim(strtok($string, '|'));

Once you've properly escaped the $data, you can INSERT them into your database, like so:

$query = "INSERT INTO table_name VALUES ($data)";
$result = mysqli_query($conn, $query);
于 2013-11-03T18:37:12.727 回答
1
$split = explode('|', $string);
$before_pipe = trim($split[0]);
于 2013-11-03T18:31:20.630 回答