TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

23 lines
451 B

--TEST--
count array_unique result for duplicate detection
--FILE--
<?php
function duplicate_count(array $values): int
{
$allValues = count($values);
$uniqueValues = count(array_unique($values));
return $allValues - $uniqueValues;
}
function main(): void
{
var_dump(duplicate_count(['a', 'b', 'a', 'c', 'b']));
var_dump(duplicate_count([1, '1', true, 2]));
var_dump(duplicate_count([]));
}
?>
--EXPECT--
int(2)
int(2)
int(0)