Suppose I am looping an array like this:
foreach($cursor as $obj) { ... }
and the values inside are as following:
$obj['name'] => "foo"
$obj['surname'] => "test"
is there a way to add another key and value inside it, directly from the foreach, without using '&'? Something like this:
foreach($cursor as $obj) { $obj['age'] = 24; }
but without using this:
foreach($cursor as &$obj) { $obj['age'] = 24; }
Thanks in advance.
foreach ($cursor as $key => $obj) {$cursor[$key]['age'] = 24;}