Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

add array to another array in laravel collection

$collection = collect(['product_id' => 1, 'price' => 100]);
 
$merged = $collection->merge(['price' => 200, 'discount' => false]);
 
$merged->all();
 
// ['product_id' => 1, 'price' => 200, 'discount' => false]
 
PREVIOUS NEXT
Tagged: #add #array #array #laravel #collection
ADD COMMENT
Topic
Name
9+5 =