Created
March 27, 2017 12:42
-
-
Save rajvanshipradeep15/1b8853042accc93d2d717303ec8f120d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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