I have a query and it is as follows.
My goal is to replace the values of all fruits to increase the price by 5%:
// precios originales
$precios = array (
"frutas" => array (
"manzanas" => 15,
"peras" => 5,
"naranjas" => 3,
),
"verduras" => array (
"clave" => 15,
"clave2" => 5,
"clave3" => 3,
)
);
// Los precios de frutas suben 5%
foreach ($precios['frutas'] as $clave => $valor) {
$nuevovalor = $valor*5/100+$valor;
$valor = ceil($nuevovalor);
}
// los precios de las verduras suben un 3%
foreach ($precios['verduras'] as $clave => $valor) {
$nuevovalor = $valor*3/100+$valor;
$valor = ceil($nuevovalor);
}
My idea is to use the function array_replace
but until here I come, nothing I did seems to work to replace the values with the new prices, this in case the new prices are well resolved with that function, your idea It will be welcome, greetings.