adding value of numbers from 2 arrays

I have a form that is working except for that I can’t get the total amount from the two different arrays i have. $total = $extras + $additional isn’t working and honestly, i have a feeling that it is not going to be that easy anyway! … Any suggestions on what formula to use so that I can get a total dollar amount of all of the options that are selected?

One more thing…Can anyone with a fresh set of eyes see why the checkbox options are all being produced in a whole new table and not just a new row? I don’t know if i can look through any more sets of

and tags! LOL

Thanks!!!

[php]<?php

$value = array(“Short Trip”=>15.99, “Long Trip”=>28.00, “Overnight”=>10.00);

if(isset($_POST[‘travel’])) {
$extras = array(“brush”=>1.50, “shampoo”=>1.50, “toothpaste”=>1.50, “cream rinse”=>1.50);
if (isset($_POST[‘extras’])) {
foreach ($_POST[‘extras’] as $additional) {
echo “<table border =“2”>

Item Charges
“.$_POST[‘travel’].”
$”.$value[$_POST[‘travel’]]."
<td>".$additional."</td>
<td> $".$extras[$additional]."</td>

</tr>
			<tr><td>Your total</td> <td>".$total."</td></tr>
			</table>";
	}
}

}

?>

Stay Information
Short trip $15.99 Long trip $28.00
Overnight $10.00
What will you need?($1.50 each)
Brush Shampoo
Toothpaste Cream Rinse

[/php]

Hi there,

Just after this line:
[php]
foreach($_POST[‘extras’] as $additional){
[/php]
Append this:
[php] $total=number_format(($value[$_POST[‘travel’]] + $additional), 2, ‘.’, ‘,’);
[/php]

As to your checkbox that gets printed in a new table, you may remove these few lines:
[php]

[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service