0

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);
    }

    Model::insert(array($dataArrayNames));

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'

1 Answer 1

2

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

Model::insert($dataArrayNames);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.