Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CanadianDeer's avatar

Error Array to string conversion in my form

Hello, I have in my form a multiple select. When i click to my submit button I have this error: Array to string conversion I want to push values in my column activite in my database. Do you have idea how to fix that?

$seller->activite = array($request['activite']);

Thanks

0 likes
6 replies
aswinghosh's avatar

use implode function of php.


$seller->activite = implode(",",$request['activite']);


manishanaik's avatar

Please check whats the value of $request->all() before pushing values to db and please make sure you have activite as the name of the select box.

munazzil's avatar

Try to use as like below,

       $seller->activite = $request->activite;
CanadianDeer's avatar
CanadianDeer
OP
Best Answer
Level 1

I find the solution:


$seller->activite = implode(',', array_values($request['activite']));

Thanks all

2 likes
rawilk's avatar

You could also just cast it to an array on your model and eliminate the need for implode.

2 likes

Please or to participate in this conversation.