With the following array
$ar = array (
//color, amount, 1/0
"red,10,0",
"red,20,1",
"red,30,0",
"red,40,1",
//"red,n,0 or 1" n: means infinite
"blue,10,0",
"blue,20,1",
"blue,30,0",
"blue,40,1",
//"blue,n,0 or 1" n: means infinite
);
I would have a function with the following echo
if color=red && amount=10 then 0
if color=red && amount=11 then 1
if color=red && amount=20 then 1
if color=red && amount=21 then 0
...
if color=blue && amount=25 then 0
many thanks
array interval
Moderator: General Moderators
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
Re: array interval
iterate through the array, explode each element on the comma, iterate through this new array.
http://us.php.net/manual/en/control-structures.for.php
http://us.php.net/manual/en/function.explode.php
http://us.php.net/manual/en/control-structures.for.php
http://us.php.net/manual/en/function.explode.php