0

I have array, so i want to store all of in array to DB horizontally

This Is My Code :

$tes = ['table','chair','computer'];
for ($i = 0; $i < count($tes); $i++) {
     $a = $tes[$i];
     DB::table('store')
         ->where('material_number', $material_number)
         ->update([
             'name' => $a,
         ]);
 }

I want to store to row name like this table,chair,computer 1 row in DB

Can anyone help me? Thanks.

1 Answer 1

2

checked code :

$tes = ['table','chair','computer'];
$names = implode(',', $tes);

// Output : table,chair,computer

DB::table('store')
   ->where('material_number', $material_number)
   ->update([
       'name' => $names,
   ]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.