This is my code:
foreach ($all_orders as $order){//the $all_orders array contains a number of arrays, so it's a multidimensional array
$order["Order Rank"]=$order[0];
unset($order[0]);
}
after renaming the key with the new key and when i print the array:
print_r($all_orders);
i got the old key name (which is 0):
Array
(
[0] => Array
(
[0] => 1
)
why it’s not :
Array
(
[0] => Array
(
["Order Rank"] => 1
)
am i missing something? thanx in advance.
You’re modifying a copy of the element.
Use references: