Check if the array contains only one key / value

$foo = array('one'); $foofoo = array('onekey' => 'onevalue'); 

How to check if an array contains only one key?

+6
source share
1 answer

count() will tell you how many elements are in the array

 if (count($foo) === 1) { echo 'This array contains one value'; } 
+21
source

Source: https://habr.com/ru/post/914483/


All Articles