RE: [PHP-WIN] Question concerning SWITCH and Comparisons
| From: | Tony Devlin | Date: | Thu, 11 Nov 2004 20:13:52 +0000 |
| Subject: | RE: [PHP-WIN] Question concerning SWITCH and Comparisons | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-24970@lists.php.net to get a copy of this message | ||
I wanna thank everyone for helping me. It seems I had it right was only
conceptually making it more
complex than it needed to be. BTW the code I wrote down I did as an example
here, not one that I
actually wrote and tested -- I was trying to conceptually design the switch
statement before I began
coding to make sure that what I was thinking was correct. After trying to
think too indept and not
coming up with my own definitive answer I decide to post my thoughts and ask
suggestion here.
I greatly appreciate the community and it's support.
Thanks,
Tony D.
-----Original Message-----
From: Alejandro César Garrammone [mailto:agarrammone@afip.gov.ar]
Sent: Thursday, November 11, 2004 2:55 PM
To: tdevlin@airewaves.com; Php-Windows
Subject: Re: [PHP-WIN] Question concerning SWITCH and Comparisons
I think this may work...but doing some debbuging I suggest:
case ($qty>=1600 and $qty< 2400): //$qty is less than 2400
and I modified the semi-colon of this part of code:
case ($qty >= 2400): //$qty is greater than or equal to 2400
I tried your code and It works!
Hope this helps,
Alex
----- Original Message -----
From: "Tony Devlin" <tdevlin@airewaves.com>
To: "Php-Windows" <php-windows@lists.php.net>
Sent: Thursday, November 11, 2004 2:35 PM
Subject: [PHP-WIN] Question concerning SWITCH and Comparisons
> If my understanding of SWITCH is correct, it stops at the first case
> that
> matches the result, correct?
>
> So then.. If I have a switch as such;
>
> switch($qty){
>
> case ($qty < 1600): //$qty is less than 1600
> do something
> break;
>
> case ($qty < 2400): //$qty is less than 2400
> do something
> break;
>
> case ($qty >= 2400); //$qty is greater than or equal to 2400
> do something
> break;
>
> default:
> do something
> break;
> }
>
> Then assuming $qty = 800, it should stop at the first case? right?
>
> a $qty of 1601 should stop at the second case?
>
> and a qty of greater than or equal to 2400 should stop at the last case?
>
> Am I correct with my switch statement then?
>
> My desired result is;
>
> If quantity is less than 1600 set price = whatever;
> or if quantity is equal to 1600 and less than 2400 set price = whatever,
> or finally if quantity is equal to or greater than 2400 set price =
> whatever.
>
> I'm having difficulties for whatever reason to come up with a proper
> comparison
> for the switch to work as described. Can someone help me iron out this
> small problem?
>
>
> Much thanks for the help,
>
> Tony D.
>