Jump to content

Arrays


Herman Wiid

Recommended Posts

it can be in an array,

maybe you can put something like this on your form:

 

<input type="checkbox" name="pepsi" value="1.00" />Pepsi<br />

<input type="checkbox" name="coke" value="1.25" />Coke<br />

<input type="checkbox" name="sprite" value="1.50" />Sprite

 

then on the php that processes it just do something like this:

 

<?php

$soda['pepsi'] = $_POST['pepsi'];
$soda['coke'] = $_POST['coke'];
$soda['sprite'] = $_POST['sprite'];

foreach($soda as $name => $value){
echo "You purchase a $name for \$$value<br />\n";
}

// if you want to add them....

echo "Your total price is ". array_sum($soda);

?>

Link to comment
https://forums.phpfreaks.com/topic/96044-arrays/#findComment-491747
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.