Foreach and adding
Posted: Thu Sep 23, 2004 9:57 pm
I have a script that adds checkboxes values to an array, and I can print them out using
Each checkbox corresponds to a product, and then adds it to the array, and when i print the array on the second page, how do I get the values separated so I can put the prices on?
Suppose I check Calea. On the post page, i include a file with a bunch of variables, and Calea is assigned the price of 5. How do I see if calea is in the array, and then add 5 dollars to a sum if it is?
Code: Select all
<?php
foreach($_POST['array'] as $key => $value) {
echo $value."<br />";
}
?>Suppose I check Calea. On the post page, i include a file with a bunch of variables, and Calea is assigned the price of 5. How do I see if calea is in the array, and then add 5 dollars to a sum if it is?