count duplicate values in array in php

<?php
 
$name= array("raj","dinesh","mota","kunal","sam","kunal","raj","raj");

$res = array_count_values($name);

print_r($res);

It shows no. of duplicates found against.
like:
raj => 3
kunal => 2
dinesh => 1
etc
?>

Leave a Reply

Your email address will not be published. Required fields are marked *