There are maximum 8 <select name="a">
and I need to store these values in an array
$a = $_POST['a'];
$b = $_POST['b'];
if (isset($a, $b)) {
foreach ($products as $thisProduct) {
if ($thisProduct->getId() == $a) {
//do something & store in array
switch($b){
case "one":
//do something
break;
case "two":
//do something
break;
case "three":
//do something
break;
}
}
}
}
//call array and make array_sum()...
How do I store these in an array so I could use this array for making calculations?
UPDATE
There are also 8 input
fields with an amount. This input
multiply with the value of $a
.
foreach ($products as $thisProduct) {
foreach ($a as $value) {
if ($thisProduct->getId() == $value) {
$multiply = ($thisProduct->getMultiply($amount));
array_push($array, $multiply);
}
}
}
How can I link each input
to the select name="[a]"
?
Use <select name=a[]>
and use this code
$a = $_POST['a'];
foreach($a as $value){
// do something
}