I need to perform a a task when there are some values in my array. So I used count
count($_SESSION['arrayValues'][$_SESSION['event']]);
And my code acts as if there’s something in the array, however when I do print_r I get the following:
Array ( [0] => )
So I suppose I need to count values. Tried using array_count_values but it does not seem to work for me… I’m a bit confused now.
count()will do that, and just fine. I’m guessing something is wrong with your array key access. Try doing a big old:print_r($_SESSION)and make sure your keys are set up as expected and your
$_SESSION['event']isn’t being populated incorrectly. Also, you’re accessing$_SESSION['arrayValues'][$_SESSION['event']], not$_SESSION['arrayValues']['event'], whether you mean to or not.