Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #12649 > unrolled thread
| Started by | richard <noreply@example.com> |
|---|---|
| First post | 2014-01-13 18:35 -0500 |
| Last post | 2014-03-11 18:51 -0500 |
| Articles | 10 — 9 participants |
Back to article view | Back to comp.lang.php
switch with range of comparisons richard <noreply@example.com> - 2014-01-13 18:35 -0500
Re: switch with range of comparisons Scott Johnson <noonehome@chalupasworld.com> - 2014-01-13 16:14 -0800
Re: switch with range of comparisons "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> - 2014-01-14 00:30 +0000
Re: switch with range of comparisons Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-14 01:36 +0000
Re: switch with range of comparisons "Peter H. Coffin" <hellsop@ninehells.com> - 2014-01-13 18:54 -0600
Re: switch with range of comparisons Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-01-14 01:26 +0000
Re: switch with range of comparisons bill <william@TechServSys.com> - 2014-01-14 06:38 -0500
Re: switch with range of comparisons daniel@honestempire.com - 2014-01-22 14:44 -0800
Re: switch with range of comparisons Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-23 00:18 +0000
Re: switch with range of comparisons testmehere@gmail.com (Jason) - 2014-03-11 18:51 -0500
| From | richard <noreply@example.com> |
|---|---|
| Date | 2014-01-13 18:35 -0500 |
| Subject | switch with range of comparisons |
| Message-ID | <19ycnlnq3bdux$.jp8vxofzg98i.dlg@40tude.net> |
switch ($value){
case "A">="Z";
}
Would this be allowed?
What I want to do is to have one case for all 26 letters of the alphabet
without having to use ||.
[toc] | [next] | [standalone]
| From | Scott Johnson <noonehome@chalupasworld.com> |
|---|---|
| Date | 2014-01-13 16:14 -0800 |
| Message-ID | <lb1vi1$kh8$1@dont-email.me> |
| In reply to | #12649 |
On 1/13/2014 3:35 PM, richard wrote:
> switch ($value){
>
> case "A">="Z";
>
>
> }
>
> Would this be allowed?
>
> What I want to do is to have one case for all 26 letters of the alphabet
> without having to use ||.
>
Why don't you venture into the if()..elseif() schema.
Or...
have 26 cases that just drop thru to the last one that does the processing.
This was you can eventually add needed code for the ones that need it.
Scotty
[toc] | [prev] | [next] | [standalone]
| From | "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> |
|---|---|
| Date | 2014-01-14 00:30 +0000 |
| Message-ID | <lb20e8$muh$1@dont-email.me> |
| In reply to | #12649 |
richard the sto0pid wrote:
> switch ($value){
>
> case "A">="Z";
>
> }
>
> Would this be allowed?
How will "A" ever be equal-to or greater-than "Z"?
> What I want to do is to have one case for all 26 letters of the alphabet
> without having to use ||.
Why would you want to use switch for only one condition?
Go to your local big box store and purchase a carton of Logic.
--
-bts
-who opened a Pandora's Box, introducing RtS to "switch"
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2014-01-14 01:36 +0000 |
| Message-ID | <lb24av$k2a$7@dont-email.me> |
| In reply to | #12652 |
On Tue, 14 Jan 2014 00:30:00 +0000, Beauregard T. Shagnasty wrote:
> richard the sto0pid wrote:
>
>> switch ($value){
>>
>> case "A">="Z";
>>
>> }
>>
>> Would this be allowed?
>
> How will "A" ever be equal-to or greater-than "Z"?
>
>> What I want to do is to have one case for all 26 letters of the
>> alphabet without having to use ||.
>
> Why would you want to use switch for only one condition?
>
> Go to your local big box store and purchase a carton of Logic.
I think what richard meant to ask was:
will
case >=A && <=Z :
work
But he couldn't even figure that out, and he obviously didn't run my
example php program that attempted to show him that he was working from a
flawed understanding.
Oh well, roll on the fucked up code.
As for whether it will work or not, well I'm buggered if I can be arsed
to help richard any more. He can find out for himself.
And now for a special message to richard:
richard, your comprehension of how switch statements work is currently so
fucked up that you are presently incapable of coding one that does what
you want, even if it appears to do so under test conditions with the
limited test data that you feed it. I strongly suggest you take a
sabbatical from your project to learn basic php programming syntax before
doing any more work on your website. 50 years might do it, although with
your current record, it might be best to set aside at least 300.
--
Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | "Peter H. Coffin" <hellsop@ninehells.com> |
|---|---|
| Date | 2014-01-13 18:54 -0600 |
| Message-ID | <slrnld92mq.v5n.hellsop@nibelheim.ninehells.com> |
| In reply to | #12649 |
On Mon, 13 Jan 2014 18:35:07 -0500, richard wrote:
> switch ($value){
>
> case "A">="Z";
>
>
> }
>
> Would this be allowed?
Allowed? Yes. Does it solve your problem? Probably not. That case will
never be executed unless $value contains something that evaluates to
false. As "A">="Z" does.
> What I want to do is to have one case for all 26 letters of the
> alphabet without having to use ||.
Back further up. Most ways of answering that question are probably
useless. What problem are you trying to solve?
--
10. I will not interrogate my enemies in the inner sanctum -- a small
hotel well outside my borders will work just as well.
--Peter Anspach's list of things to do as an Evil Overlord
[toc] | [prev] | [next] | [standalone]
| From | Doug Miller <doug_at_milmac_dot_com@example.com> |
|---|---|
| Date | 2014-01-14 01:26 +0000 |
| Message-ID | <XnsA2B4CFE053082dougmilmaccom@78.46.70.116> |
| In reply to | #12649 |
richard <noreply@example.com> wrote in news:19ycnlnq3bdux$.jp8vxofzg98i.dlg@
40tude.net:
> switch ($value){
>
> case "A">="Z";
>
>
> }
>
> Would this be allowed?
Yes, it's allowed.
It's equivalent to
switch ($value) {
case false:
...
}
> What I want to do is to have one case for all 26 letters of the alphabet
> without having to use ||.
That won't do what you want. Neither will ||, for reasons that have already been explained.
Why not just code a simple if statement to test if $value is between "A" and "Z" ?
[toc] | [prev] | [next] | [standalone]
| From | bill <william@TechServSys.com> |
|---|---|
| Date | 2014-01-14 06:38 -0500 |
| Message-ID | <lb37j9$e6j$2@speranza.aioe.org> |
| In reply to | #12654 |
On 1/13/2014 8:26 PM, Doug Miller wrote: > } > >> What I want to do is to have one case for all 26 letters of the alphabet >> without having to use ||. > > That won't do what you want. Neither will ||, for reasons that have already been explained. > > Why not just code a simple if statement to test if $value is between "A" and "Z" ? > > > > > should we tell richard about regex ? no !
[toc] | [prev] | [next] | [standalone]
| From | daniel@honestempire.com |
|---|---|
| Date | 2014-01-22 14:44 -0800 |
| Message-ID | <948d96c7-2cb3-4c73-8f8a-c9d744430b13@googlegroups.com> |
| In reply to | #12649 |
On Monday, 13 January 2014 23:35:07 UTC, richard wrote:
> switch ($value){
>
>
>
> case "A">="Z";
>
>
>
>
>
> }
>
>
>
> Would this be allowed?
>
>
>
> What I want to do is to have one case for all 26 letters of the alphabet
>
> without having to use ||.
Take a look at preg_match() or ctype_alpha()
http://uk1.php.net/preg_match
http://www.php.net/manual/en/function.ctype-alpha.php
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2014-01-23 00:18 +0000 |
| Message-ID | <lbpn4v$668$5@dont-email.me> |
| In reply to | #12649 |
On Mon, 13 Jan 2014 18:35:07 -0500, richard wrote:
> What I want to do is to have one case for all 26 letters of the alphabet
> without having to use ||.
You can only match 1 possible value of the test variable with each case
statement in php.
You can not match multiple possible values of the test variable in a
single case statement in php.
If you wish to match multiple values, you can stack case statements.
The case statement comparison is a coercive equality test, ie it will
coerce both objects being compared so that it can make a meaningful test
for equality.
Here is an example of multiple tests all executing the same code branch
in a switch statement:
switch ( $x ) {
case "fish":
case "chips":
case "sausages":
case "peas":
case "beans":
case "burgers":
echo "food";
break;
case "salt":
case "pepper":
case "vinegar":
case "ketchup":
echo "Condiment";
break;
case "water":
case "beer":
case "whisky":
case "vodka":
case "cola":
case "milk":
case "coffee":
echo "beverage";
break;
default:
echo "Are you sure you want to consume that?";
break;
}
I eagerly await your next example of how to fuck up a switch statement.
--
Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | testmehere@gmail.com (Jason) |
|---|---|
| Date | 2014-03-11 18:51 -0500 |
| Message-ID | <F7mdnXPpucXnPILOnZ2dnUVZ_q-dnZ2d@giganews.com> |
| In reply to | #12705 |
Denis McMahon wrote:
>
> On Mon, 13 Jan 2014 18:35:07 -0500, richard wrote:
>
> > What I want to do is to have one case for all 26 letters of the alphabet
> > without having to use ||.
>
> You can only match 1 possible value of the test variable with each case
> statement in php.
>
> You can not match multiple possible values of the test variable in a
> single case statement in php.
>
> If you wish to match multiple values, you can stack case statements.
>
> The case statement comparison is a coercive equality test, ie it will
> coerce both objects being compared so that it can make a meaningful test
> for equality.
>
> Here is an example of multiple tests all executing the same code branch
> in a switch statement:
>
> switch ( $x ) {
>
> case "fish":
> case "chips":
> case "sausages":
> case "peas":
> case "beans":
> case "burgers":
> echo "food";
> break;
>
> case "salt":
> case "pepper":
> case "vinegar":
> case "ketchup":
> echo "Condiment";
> break;
>
> case "water":
> case "beer":
> case "whisky":
> case "vodka":
> case "cola":
> case "milk":
> case "coffee":
> echo "beverage";
> break;
>
> default:
> echo "Are you sure you want to consume that?";
> break;
>
> }
>
> I eagerly await your next example of how to fuck up a switch statement.
>
--
----== posted via BitOnWire.com ==----
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web