I have a variable, and I need to only add it to an array if it contains something other than spaces.
Up until now I had been using $var != ''
. That only covers if it's an empty string. I need i开发者_如何转开发t to cover if it has spaces in it.
This will check if a string contains at least one non-whitespace character. Whitespace includes spaces, newlines, tabs, etc.
trim($var) != ''
have you tried empty() ?
trim($var, ' ') != ''
精彩评论