Skip to content
Advertisement

Check and return duplicates array php

I would like to check if my array has any duplicates and return the duplicated values in an array. I want this to be as efficient as possible.

Example:

JavaScript

Also the initial array is always 5 positions long

Advertisement

Answer

this will be ~100 times faster than array_diff

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement