RE: Question concerning SWITCH and Comparisons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx]
Sent: Thursday, November 11, 2004 2:55 PM
To: tdevlin@xxxxxxxxxxxxx; Php-Windows
Subject: Re:  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@xxxxxxxxxxxxx>
To: "Php-Windows" <php-windows@xxxxxxxxxxxxx>
Sent: Thursday, November 11, 2004 2:35 PM
Subject:  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.
>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux