Page 1 of 1

Variable is a String or an Array

Posted: Tue Aug 10, 2010 5:07 pm
by avivm3
This seems like a really obvious question, but I'm tired of struggling for the answer.

I have an IF statement that I want to trigger ONLY if the variable I provide is a single value (Number or String). I DON'T want it running if the variable is an Array. What statement should I use to check if it's an array, and won't error out if it's not?

Re: Variable is a String or an Array

Posted: Tue Aug 10, 2010 5:34 pm
by cpetercarter
The functions which test the type of a variable are is_array(), is_int(), is_float(), is_string(), is_object(). Between them I think you can achieve what you want!

Re: Variable is a String or an Array

Posted: Tue Aug 10, 2010 7:43 pm
by avivm3
Perfect. Thanks!