Hey people,
What's the proper way to write this?
if ( $state == ('CA', 'CO', 'FL', 'ID', 'IL', 'IN', 'IA', 'MI', 'MN', 'MO', 'NM', 'ND', 'OR', 'RI', 'SD', 'TN', 'UT', 'VT', 'VA', 'WA', 'WI', 'WY') );
Thanks for the help in advance!
By using an array and in_array.
$good = array('a','b','c'); if (in_array($something, $good)) { }
Originally posted by brianb Hey people, What's the proper way to write this? if ( $state == ('CA', 'CO', 'FL', 'ID', 'IL', 'IN', 'IA', 'MI', 'MN', 'MO', 'NM', 'ND', 'OR', 'RI', 'SD', 'TN', 'UT', 'VT', 'VA', 'WA', 'WI', 'WY') ); Thanks for the help in advance!
As far as I know you have to use "OR"
if (($state=="CA") OR ($state=="CO") OR ($state=="FL"))
There may be an easier way, but you could do: if ( $state == 'CA' || $state == 'CO' || ..etc )
Or, you could use a switch statement if php supports it (I'm not sure, im a C++ programmer myself and I'm just learning php), as I expect it will.
~ Paul
The first poster's solution worked like a charm!
Thanks guys!