PHP array_count_values() Function6 Jan 2025 | 1 min read The array_count_values() function returns an array where the keys are the original array's values, and the values is the number of occurrences. In other words, we can say that array_count_values() function is used to calculate the frequency of all of the elements of an array. Syntax
Return TypeReturns an associative array, where the keys are the original array's values, and the values are the number of occurrences. This function is introduced in PHP 4 Example 1Output: Array( [3] => 2 [Hii] => 2 [World] => 1 ) Example 2Output: Array( [php] => 3 [T] => 2 [Point] => 1 ) Example 3Output: Array ( [Ajay]=>2 [Sid]=>2 [Rahul]=>1 [Ashish]=>1 ) Example 4Output: Array ( [Cricket] => 1 [Hockey] => 2 [Football] => 1 ) Next TopicPhp-array-current-function |
The array_replace() function is a built-in function in PHP. The PHP array_replace( ) function is used to replace the values of the first array with the values from following arrays. This function was introduced in PHP 5.3.0. Syntax array array_replace ( array $array1 [, array $... ]...
1 min read
The array_uintersect_uassoc( ) is an inbuilt function of PHP. The array_uintersect_uassoc() function uses two user-defined functions to compare the keys and values of two or more arrays, and returns the matches. This function was introduced in PHP 5.0. Syntax array array_uintersect_uassoc ( array $array1 , array $array2...
1 min read
PHP list() Function The PHP list( ) function is used to assign values to a list of variables in one operation. This function was introduced in PHP 4.0. Syntax array list ( mixed $var1 [, mixed $... ] ); Parameter Parameter Description Is compulsory Variable1 The first variable to assign a value to. compulsory Variable2... More variables...
1 min read
PHP shuffle() Function The PHP shuffle( ) function is used to randomize the order of the elements in the array. The function assigns new keys to the elements in an array. This function introduced in PHP 4.0. Syntax bool shuffle ( array &$array ); Parameter Parameter Description Is compulsory array Specifies the array to...
1 min read
The array_search() function is an inbuilt function of PHP. It is used to search the array against the given value. The function returns the first corresponding key if successful. This function was introduced in PHP 4.0.5. Syntax mixed array_search ( mixed $needle , array $haystack [, bool...
1 min read
PHP array_unique( ) Function The array_unique( ) function is an inbuilt function of PHP and it is used to remove duplicate values from an array. This function was introduced in 4.0.1 Syntax array array_unique ( array $array [, int $sort_flags = SORT_STRING ] ); Parameters Parameter Description Is compulsory array1 The input array. compulsory sort_flags The optional...
1 min read
The array_udiff_assoc( ) function is an inbuilt function of PHP. The array_udiff_assoc( ) function use a built-in function to compare the keys and values of two or more arrays, and returns the differences. This function was introduced in PHP 5.0. Syntax array array_udiff_assoc ( array $array1 ,...
1 min read
This function is used to flip the array with the keys and values. It takes one parameter that is an array. The returned array will contain the flipped elements. The values will be the keys, and the keys will be the values. This function was...
1 min read
The array_product() function is inbuilt function of PHP. The array_product() function calculates the product of an array. This function was introduced in PHP 5.1.0. Syntax number array_product ( array $array ); Parameters Parameter Description Required/Optional array Specifies an array. compulsory Return Type The array_product() function returns the product as an integer or float. Example 1 <?php $prime=array(2,3,5,7); print_r(array_product($prime)); ?> Output: 210 Example 2 <?php $even=array(2,6); print_r($even); print_r(array_product($even)); echo "\n"; $odd=array(7,9); print_r($odd); print_r(array_product($odd)); ?> Output: Array ( ...
1 min read
The array_key_exists( ) is an builtin function of PHP. The array_key_exists( ) function checks an array for a specified key, and returns true if the key exists and false if the key does not exists. This function was introduced in PHP 4.0.7. Syntax array_key_exists(key,array); Parameter Description Is compulsory key Specifies the key. compulsory array Specifies...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India