Answers for "count same values in array php"

PHP
2

php count amount of times a value appears in array

$tmp = array_count_values($uid);
$cnt = $tmp[12];
//Or
$cnt = count(array_filter($uid,function($a) {return $a==12;}));
//In both cases $var will be a number
Posted by: Guest on May-14-2020
0

check if any values are the same in an array php

if(count(array_unique($array, SORT_REGULAR)) < count($array)) {
    // $array has duplicates
} else {
    // $array does not have duplicates
}
Posted by: Guest on July-08-2020

Code answers related to "count same values in array php"

Browse Popular Code Answers by Language