user2258313 user2258313 - 3 months ago 30
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
count($_COOKIE["ONLY THE VALUE"]);


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.

Answer

Use array_count_values.

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