severndigital Posted July 23, 2009 Share Posted July 23, 2009 i would like to do something like this $var1 = 'yes'; $var2 = ''; $var3 = 'yes'; if(empty($var1) || empty($var2) || empty($var3)){ echo 'var2 is empty'; } I know that's not right, but it was the easiest way to explain what I am trying to do. can anyone help? Thanks. -P Quote Link to comment Share on other sites More sharing options...
akitchin Posted July 23, 2009 Share Posted July 23, 2009 this is a little tough to do without knowing more about the variables. are you able to put them into an array, rather than number them sequentially? if you can't do that, do you have some way of knowing how many variables there are? Quote Link to comment Share on other sites More sharing options...
ldougherty Posted July 23, 2009 Share Posted July 23, 2009 Your logic is not far off, assuming the variables are just plain variables and not arrays you could use the isset function to determine if the variable has a value or not. http://us.php.net/isset Simply use it like If (!isset($var1)) { echo "var1 is empty"; } That states if $var1 is NOT SET then echo it is empty. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.