I like the "IN" function in SQL: select * from table where id IN(1,3,4,7);
I was wondering if PHP has a similar, compact, way to ask if a variable is any of several values? I don't like the "switch" syntax. Can never memorize it... _;
No, I really like the IN syntax too, here is the hard way to do it.
function IN($what,$array) { for($i=0;$i<count($array);$i++) { if($what == $array[$i]) { return(1); } return(0); }
if(IN('a',array('a','b','c'))) { print("in\n"); }
hmm... there's also a php function that does that... in_array() 🙂
but what if it's not an array you're searching?
then use strstr()
yeah, i knew that. its early
smiles Yes, I suppose in_array is the closest thing. Thanks for your help.