[Solved] How do i multiply values of an array


You are not reconstructing an array in your foreach loop. So your $od variable does just get overridden each time you loop.

Your code should be

foreach($_POST['gm'] as $key => $answer) {
    if($answer != '') {
        $odd = explode(" ",$answer);
        $od[] = trim($odd[0]);
    }
}
$total = array_product($od);
echo $total;

0

solved How do i multiply values of an array