Gammer
Gammer

Reputation: 5628

Laravel 5.2 : One database field many values seperated with comma

I am using laravel 5.2, I am stuck in a case,Where i have one db field product_specs and 5 form input inserting their values to that same product_specs database field.

My question is that how can i add comma to values and then insert it to the database field product_specs.

Then i will be able to use php function explode() to remove the comma and use the result.

Upvotes: 1

Views: 335

Answers (2)

syszen
syszen

Reputation: 202

just concatenate and insert on db ?

$product_specs = $value1 . ',' . $value2 . ',' .....;
//insert $product_specs on db field product_specs

then when need fetch the data and implode the previous answer

hope it helps if thats your question

Upvotes: -1

Alexey Mezenin
Alexey Mezenin

Reputation: 163898

How about the implode() function?

$comma_separated = implode(",", $array);

Upvotes: 4

Related Questions