jwhite68 Posted July 20, 2007 Share Posted July 20, 2007 I have an array: $errs = array(); And in the code, I want to check if the array has any values assigned to its elements. e.g. if $errs[1] or $errs[2] have been set to values then its not empty. But if no elements (ie no keys) have been assigned to the array, how can I easily check for this? I think I have been through the various array functions in PHP and couldnt see anything obvious. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted July 20, 2007 Share Posted July 20, 2007 if(count($array) > 0) { echo "is not empty"; } else { echo "is empty"; } Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 20, 2007 Share Posted July 20, 2007 u may also used if(empty($array)) { print "array 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.