user2258313 user2258313 - 10 months ago 70
PHP Question

PHP Count number of Cookies with Specific Value

I'd like to count the number of cookies with a specific value in this case the value is 'complete' but the cookie key's will be unique. So there might be

key1 = complete
key 2 = complete
but I can't seem to find anyway to do

I'm sure its obvious but after days of trying to figure out how I've hit a stump.

Any help would be greatly appreciated.


Use array_count_values.

$count = array_count_values($_COOKIE);
echo $count["complete"]; // gives you the count for that value