On Fri, 11 Jun 2004 10:53:37 +0100, "Nel" <ne***@ne14.co.NOSPAMuk>
wrote:
"Marc Labtec" <ph*@komatia.com> wrote in message
news:ad**************************@posting.google. com... Hi all,
:)
I have an URL like this index.php?a=0&b=0&c=1&d=0&e=0&f=0
My prob now is: how can I find out if only *one* get var (a,b,d,d,e,f)
is 1?
I dopn't care about the other, i must detect, if *only one* var in the
url has its value 1, and all others are 0 then...
Thanks in advance - you are a great group here!
Marc
I am sure there are several ways to do this, but if you know that the values
will always be 1 or 0, you could simply add the values together.
if ($a+$b+$c+$d+$e+$f == 1) { OK } else { NOT OK }
But as they're being passed by GET, none of the values can be
guaranteed.
Also, what about these scenarios:
index.php?a=-1&b=1&c=1&d=0&e=0&f=0
index.php?a=0&b=1&c=2&d=3&e=4&f=5
index.php?a=0&b=0&c=1&d=0&e=0&f=0&g=1&h=1&i=0
index.php?a=1
From the OP:
My prob now is: how can I find out if only *one* get var (a,b,d,d,e,f)
is 1?
I dopn't care about the other, i must detect, if *only one* var in the
url has its value 1, and all others are 0 then...
There is a contradiction here. He says "I don't care about the other",
but then says "if *only one* var in the url has its value 1, and all
others are 0 then..."
So, must the other GET variables be zero or not?
You could iterate through the $_GET[] array, making a count of the 1's
and 0's and then test those counts. The sum of the counts should equal
the number of GET variables.
--
David ( @priz.co.uk )