I am not very familiar with php arrays and trying to change value of an array generated from laravel collection with no success. Here is the code :
$items = Purchase::find($id)->items->toArray();
foreach ($items as $i) {
$i['itemdesc'] = "Test";
}
info($items);
The $items array looks like this :
[2021-06-05 17:29:20] local.INFO: array (
0 =>
array (
'itemcode' => '54',
'itemdesc' => 'FARROAD 225/40ZR18 FRD26 92W XL',
),
1 =>
array (
'itemcode' => '141',
'itemdesc' => 'TRACKMAX 225/40ZR19 X-PRIVILO TX3 93Y XL',
),
The values for itemdesc are not getting changed. If I add info($i) inside the foreach loop I can see that the value is changed. Can someone help what is wrong in above code.