-1
The array has the following structure below:
$array = [
[['total_arrematado' => 27, 'id' => 5],['total_arrematado' => 10, 'id' => 7]],
[['total_arrematado' => 50, 'id' => 8],['total_arrematado' => 60, 'id' => 15]]
];
Array
(
[0] => Array
(
[0] => Array
(
[total_arrematado] => 27
[id] => 5
)
[1] => Array
(
[total_arrematado] => 10
[id] => 7
)
)
[1] => Array
(
[0] => Array
(
[total_arrematado] => 50
[id] => 8
)
[1] => Array
(
[total_arrematado] => 60
[id] => 15
)
)
)
How it would be possible to create a new key dynamically inside each array to get the following structure:
Array
(
[0] => Array
(
[0] => Array
(
[total_arrematado] => 27
[id] => 5
[total_itens] => 100
)
[1] => Array
(
[total_arrematado] => 10
[id] => 7
[total_itens] => 100
)
)
[1] => Array
(
[0] => Array
(
[total_arrematado] => 50
[id] => 8
[total_itens] => 100
)
[1] => Array
(
[total_arrematado] => 60
[id] => 15
[total_itens] => 100
)
)
)
I tried with two foreachs, but it doesn’t work:
foreach ($array as $key => $linha1) {
foreach ($linha1 as $k => $r) {
$linha1[$k]['total_itens'] = 100;
}
}
novic, perfect!!! Thanks
– Jorgito da Silva Paiva