Re: Short writage of clauses

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

 



Stut schrieb:
Jochem Maas wrote:
Stut wrote:
But it begs the question why you would want to do this?

it's a handy way to white list data. e.g.

if (in_array($_GET['yourarg'], $allowedValsForYourArg)) echo "nice arg dude";

(btw: no need to beg ;-)

I agree that the in_array function is useful, but the OP was asking for a way to shorten (a == 1 or a == 2). Maybe the question was poorly stated and meant to ask how to compare a variable to a larger number of values but that's not what I got from it.
Well that's exactly what i wanted
if (a == 1 AND a == 2 OR a ==3 OR a == c_d OR a == my_function())

i wanted to write it like:
IF (a == 1 AND 2 OR 3 OR c_d OR my_function())

YI read it as an 'I want to
save my fingers a bit of typing' and wondered if I was missing the point.
well exactly. I want to save some typing.
Having rater long variables or associative arrays is much of typing
if ($db_array["my_fieldname"] != $other_db_array["my_other_fieldname"] OR $db_array["my_fieldname"] == 2 OR $db_array["my_fieldname"] == my_very_special_functionname())

and so on.

Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux