I have a foreach loop to format an object like this :
foreach ($data as $index => $item) {
$temp = array_merge($columns['columns'], $temp);
$data->$index = (object)$temp;
}
basically I am modifying the object and I also can do it in this way
foreach ($data as &$item) {
$temp = array_merge($columns['columns'], $temp);
$item = (object)$temp;
}
Which is the best practice for modifying the object ?
