dimanche 21 juin 2020

how to change array structure from laravel collection?

im newb using laravel and i get some problem ,

i have array from laravel colection and the array look like this :

Illuminate\Support\Collection {#822 ▼
  #items: array:3 [▼
    0 => "CPU Socket LGA1151 Chipset Intel Z390  4 x DIMM Max 64GB DDR4"
    1 => "CPU Socket LGA1151 Chipset Intel Z390 4 x DIMM Max 64GB DDR4"
    2 => "Intel Core i7-9750H, 8 GB DDR4, 512 GB SSD, Nvidia GeForce GTX 1660 Ti 6 GB, 15.6 Inch Full HD"
  ]
}

and this is my code :

$samples = Product::select('details')->pluck('details');;
// dd($product);
    
dd($samples);

the problem is how to change array structure from laravel collection to be like this :

 array:2 [▼
      0 => "CPU Socket LGA1151 Chipset Intel Z390  4 x DIMM Max 64GB DDR4"
      1 => "CPU Socket LGA1151 Chipset Intel Z390 4 x DIMM Max 64GB DDR4"
      2 => "Intel Core i7-9750H, 8 GB DDR4, 512 GB SSD, Nvidia GeForce GTX 1660 Ti 6 GB, 15.6 Inch Full HD"
    ]

can somebody help me? sorry for my broken english ,thanks before.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire