I'm trying to add additional entry to an existing multidimensional array using array_push()
Here is my array: $array =
Array
(
[0] => Array
(
[label] => Black
[quantity] => 10
)
[1] => Array
(
[label] => Yellow
[quantity] => 20
)
[2] => Array
(
[label] => Red
[quantity] => 30
)
)
What I need now is to add price key after each [quantity], so the final result is:
Array
(
[0] => Array
(
[label] => Black
[quantity] => 10
[price] => 0
)
[1] => Array
(
[label] => Yellow
[quantity] => 20
[price] => 0
)
[2] => Array
(
[label] => Red
[quantity] => 30
[price] => 0
)
)
$price['price'][] = 0;
I have tried using array_push($price['price'], $array)
but that doesn't work, it just returns number 2.