johnsmith153 Posted October 6, 2008 Share Posted October 6, 2008 I need to check if an array contains at least one key. I wont know the values of the keys (could be 34434, 20, anything) but need to know if at least one value exist. It is to stop " Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object " when my array is empty Link to comment https://forums.phpfreaks.com/topic/127304-ultra-easy-check-if-an-array-contains-at-least-one-key/ Share on other sites More sharing options...
DarkWater Posted October 6, 2008 Share Posted October 6, 2008 if (count($array) > 0) { ... } Link to comment https://forums.phpfreaks.com/topic/127304-ultra-easy-check-if-an-array-contains-at-least-one-key/#findComment-658410 Share on other sites More sharing options...
johnsmith153 Posted October 6, 2008 Author Share Posted October 6, 2008 I should have know that! - pretty obvious. I tried if $array="" then got fed up. Cheers Darks. Link to comment https://forums.phpfreaks.com/topic/127304-ultra-easy-check-if-an-array-contains-at-least-one-key/#findComment-658417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.