user3356666 user3356666 - 1 year ago 81
PHP Question

Laravel inserting multiple records in table

I try to do that

$names = $request->input('name');
$forid= $request->input('forid');
$ArrayNames = explode(",",$names);

$dataArrayNames = array();
foreach($ArrayNames as $name)
$dataArrayNames[] = array('name'=>$name, 'forId' => $forid);


But i get the error message
" preg_replace(): Parameter mismatch, pattern is a string while replacement is an array "

NOTE : $request->input('name') = 'nameA,nameB,nameC'

Answer Source

You are making an array of an array. Try this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download