我想知道是否有人可以帮我解决错误。
我有以下代码:
$suburbInsert = array();
$suburbInsert[] = array(
'name' => $postalCode . ' ' . $suburbName,
'suburb_name' => $suburbName,
'pcode' => $postalCode
);
$suburbID = DB::table('suburbs')->insertGetId( $suburbInsert );
当我运行它时,我收到以下错误
{"error":{"type":"ErrorException","message":"preg_replace(): Parameter mismatch, pattern is a string while replacement is an array","file":"\/var\/www\/laravel\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/helpers.php","line":990}}
非常感谢任何帮助
答案 0 :(得分:1)
您正在创建$suburbInsert
作为数组数组。
而不是:
$suburbInsert = array();
$suburbInsert[] = array(
...
);
只是做:
$suburbInsert = array(
...
);