Code : Tout sélectionner
$total_1= array("01" => 1,"02" => 0,"03" => 2,"04" => 0);
[b]X[/b]
$total_2= array("01" => 3,"02" => 5,"03" => 2,"04" => 0);
=
$total_3= array("01" => 3,"02" => 0,"03" => 4,"04" => 0);Code : Tout sélectionner
$total_1= array("01" => 1,"02" => 0,"03" => 2,"04" => 0);
[b]X[/b]
$total_2= array("01" => 3,"02" => 5,"03" => 2,"04" => 0);
=
$total_3= array("01" => 3,"02" => 0,"03" => 4,"04" => 0);<?php
// affectation
$total_1= array("01" => 1,"02" => 0,"03" => 2,"04" => 0);
$total_2= array("01" => 3,"02" => 5,"03" => 2,"04" => 0);
// multiplication (resultat dans $total_3)
foreach($total_1 as $key => $val) {
$total_3[$key]=$total_1[$key]*$total_2[$key];
}
// verification
foreach($total_3 as $key => $val) {
echo "<BR>".$key." -> ".$val;
}
?>
function mult($a, $b)
{
return $a * $b;
}
$total_1= array("01" => 1,"02" => 2,"03" => 2,"04" => 0);
$total_2= array("01" => 3,"02" => 5,"03" => 2,"04" => 0);
$c = array_map("mult", $total_1, $total_2);
print_r($c);