PHP - array_count_values() Function Example

PHP 8 , PHP

Nicesnippets

881

05-03-2021


Hello Friends,

Now let's see example of how to use array_count_values function in php. This function can count all the values of an array. This is a short guide on php if array_count_values function. The count function is used to count the elements of an array or the properties of an object. Let's get started with array_count_values function in php.

Here i will give you example of how to use array_count_values function in php.

Syntax


array_count_values(array_variable)

Example

<!DOCTYPE html>

<html>

<head>

<title>How To Check If array_count_values Function In Php - NiceSnippets.com?</title>

</head>

<body>

<?php

$a[0] = 'Language';

$a[1] = 'Laravel';

$a[2] = 'PHP';

$a[3] = 'Java';

$a[4] = 'Language';

$result = array_count_values($a);

print_r($result);

?>

</body>

</html>

Output:

Array ( [Language] => 2 [Laravel] => 1 [PHP] => 1 [Java] => 1 )

It will help you....


Recommended Posts