Hi Shaine,
> ok question: 7days in a week.
> day 1-2 costs $10,
> day 3-5 cost $15,
> day 4-7 costs $10.
I'm assuming you meant 6-7 here instead of 4-7, otherwise you've introduced
a contradiction with days 3-5.
> how can I work out the total if someone stays from say day 2-5?
> or what about day 3-7?
Try this:
<?php
// assume $start holds start day
// assume $end holds end day
// note that the first array element is "0" - this is
// because day 0 doesn't exist :-)
$costs = array(0, 10, 10, 15, 15, 15, 10, 10);
$total = 0;
for ($i = $start; $i <= $end; $i++)
$total += $costs[$i];
echo "<p>Total is $total.</p>";
?>
Working out how to change it so people can stay from day 6 in week 1 to day
4 in week 2 is left as an exercise for the reader ;-)
Cheers
Jon
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php