I have an array of arrays, and I want to loop them while assigning a new key-value for each. But the original array fails to response. Here is my try:
<?php
$cards = array(
array(
"test" => 1
),array(
"test" => 2
)
);
foreach($cards as $card){
$card["success"] = 1;
}
print_r($cards);
OUTPUT:
Array
(
[0] => Array
(
[test] => 1
)
[1] => Array
(
[test] => 2
)
)
How can I modify the method hence the 'success' value can be inserted into each of them?