Skip to content

Instantly share code, notes, and snippets.

@rajvanshipradeep15
Created March 27, 2017 12:42
Show Gist options
  • Save rajvanshipradeep15/1b8853042accc93d2d717303ec8f120d to your computer and use it in GitHub Desktop.
Save rajvanshipradeep15/1b8853042accc93d2d717303ec8f120d to your computer and use it in GitHub Desktop.
// your code goes here
$array = array(1,2,2,4,5);
$uniqueme = array();
$duplicates = array();
foreach ($array as $key => $value) {
if( false == in_array($value,$uniqueme) ) {
$uniqueme[] = $value;
} else {
$duplicates[] = $value;
}
}
print_r($array);
print_r($duplicates);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment