function containsDuplicate($nums) { $nums = array_count_values($nums); foreach ($nums as $key => $num) { if ($num >= 2) { return true; } } return false; } echo containsDuplicate([1, 2, 3, 1]);
Pro tip: use ```triple backticks around text``` to write in code fences