function array_count_values_of($value, $array) {
    $counts = array_count_values($array);
    return $counts[$value];
}

Not native, but come on, it's simple enough. ;-)

Alternatively:

echo count(array_filter($array, function ($n) { return $n == 6; }));

Or:

echo array_reduce($array, function (n) { return n == 6); }, 0);

Or:

echo count(array_keys($array, 6));
Answer from deceze on Stack Overflow
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ php โ€บ arrays โ€บ array_count_values()
PHP | Arrays | array_count_values() | Codecademy
August 8, 2023 - The array_count_values() is a function that counts the occurrences of values in an array.
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ php โ€บ php-count-occurrences-of-specific-value-in-array
Count Occurrences of Specific Value in Array in PHP
May 8, 2023 - ... <?php $arr = ["apple", "banana", "apple", "fig", "cherry"]; $value = "apple"; $n = count(array_filter($arr, function ($item) use ($value) { return $item == $value; })); print_r("Number of occurrences : " .
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ php โ€บ php-array-count-values
PHP array_count_values() - Count all the occurrences of values in array - Examples
May 7, 2023 - PHP array_count_values() function counts the occurrences of all values in an array and returns an associative array formed by the unique value of input array as keys, and the number of their occurrences in the array as values.
๐ŸŒ
Tutorialdeep
tutorialdeep.com โ€บ knowhow โ€บ php faqs โ€บ how to count occurrence of value in array in php
How to Count Occurrence of Value in Array in PHP
August 5, 2021 - The short answer is to use the PHP array_count_values() Function of PHP that takes a single argument as an array. You can also find the number of times the specified element is present in an array. Letโ€™s find out the different methods and examples given below to learn.
๐ŸŒ
IncludeHelp
includehelp.com โ€บ php โ€บ array_count_values-function.aspx
PHP Array array_count_values() Function (With Examples)
In this tutorial, we will learn about the PHP array_count_values() function with its usage, syntax, parameters, return value, and examples. By IncludeHelp Last updated : December 31, 2023 ยท The array_count_values() function will count the occurrences of each individual element and returns ...
Find elsewhere
๐ŸŒ
IncludeHelp
includehelp.com โ€บ php โ€บ find-the-occurrences-of-a-given-element-in-an-array.aspx
PHP | Find the occurrences of a given element in an array
" time(s) in array\n"; //word/element to find the the array $word = "Hello"; //finding the occurances $wordCount = count(array_keys($array, $word)); //printing the result echo "Word <b>" . $word . "</b> Appears " . $wordCount . " time(s) in array\n"; ?> Word The Appears 2 time(s) in array Word ...
๐ŸŒ
ZetCode
zetcode.com โ€บ php-array โ€บ array-count-values
PHP array_count_values - Counting Array Values in PHP
The PHP array_count_values function counts the occurrences of values in an array.
๐ŸŒ
Reintech
reintech.io โ€บ blog โ€บ phps-array-count-values-function-complete-guide
PHP's `array_count_values()` Function: A Complete Guide
April 14, 2023 - The array_count_values() function accepts an array as input and returns an associative array where keys represent unique values from the input, and values represent their occurrence counts.
๐ŸŒ
Plus2Net
plus2net.com โ€บ php_tutorial โ€บ array_count_values.php
array_count_values: counting the frequency of elements inside array
We can count the number of time elements are present inside an array by using array_count_values function in php. This function returns another array which stores the values ( or elements ) of the input array and its frequency or the number ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ count-frequency-of-an-array-item-in-php
Count Frequency of an Array Item in PHP - GeeksforGeeks
July 23, 2025 - array_map() iterates over the unique elements and uses array_filter() to count occurrences of each element in the original array. The resulting array $freq contains the counts of each unique element.
๐ŸŒ
W3Schools
w3schools.com โ€บ php โ€บ func_array_count_values.asp
PHP array_count_values() Function
AJAX Intro AJAX PHP AJAX Database AJAX XML AJAX Live Search AJAX Poll ... PHP Examples PHP Compiler PHP Quiz PHP Exercises PHP Practice Problems PHP Server PHP Syllabus PHP Study Plan ... array() array_change_key_case() array_chunk() array_column() array_combine() array_count_values() array_diff() array_diff_assoc() array_diff_key() array_diff_uassoc() array_diff_ukey() array_fill() array_fill_keys() array_filter() array_flip() array_intersect() array_intersect_assoc() array_intersect_key() array_intersect_uassoc() array_intersect_ukey() array_key_exists() array_keys() array_map() array_merge(
๐ŸŒ
Sling Academy
slingacademy.com โ€บ article โ€บ php-how-to-count-the-occurrences-of-an-array-value
PHP: How to Count the Occurrences of an Array Value - Sling Academy
Another way to count occurrences, particularly of a single value, is to use the array_filter function combined with the count function. The array_filter function filters elements of an array using a callback function, and the count function simply counts the number of elements in an array.