【发布时间】:2023-03-29 17:00:01
【问题描述】:
我通过 JSON 获得 $id 值,当我在 $tracks WHERE 子句中使用 $id 时,它向我显示了这个错误
preg_replace():参数不匹配,pattern是字符串而replacement是数组
显示如下:
Array
$id = (
[0] => Array
(
[4843] => 4843
[4844] => 4844
)
[1] => Array
(
[396] => 396
)
[2] => Array
(
[3963] => 3963
)
)
我的控制器:
$track = Input::get('tracks');
$id = [];
foreach($track as $key => $tracks)
{
$id[] = json_decode($tracks, true);
}
$tracks = Element::with(
'composers',
'format_mp3s',
'loopsets.format_mp3s',
'mixes.format_mp3s',
'opening_key',
'closing_key',
'speed',
'mood',
'metre',
'tonic'
)
->where('id', $id)
->orderBy($sortBy, $dir)
->get();
【问题讨论】:
-
先生,当我在 where 子句中使用 $id 时,它会告诉我这个错误
-
显示
var_dump($track)的输出