Write a PHP program to check a flat list for duplicate values. Returns true if duplicate values exists and false if values are all unique.
<?php function has_Duplicates($items) { if (count($items) > count(array_unique($items))) return 1; else return 0; } print_r(has_Duplicates([1, 2, 3, 4, 5, 5])); echo "\n"; print_r(has_Duplicates([1, 2, 3, 4, 5])); ?>
Sample Output:
1 0
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer