Created
August 4, 2019 11:43
-
-
Save yasaryousuf/68c520bd52241a2d04578c3929f7209b to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
//Enter your code here, enjoy! | |
$array = [1, 2, 2, 2, 3]; | |
$newArray = []; | |
$dupCount = 0; | |
foreach($array as $el) { | |
if(in_array($el, $newArray)) { | |
$dupCount++; | |
} | |
$newArray[] = $el; | |
} | |
echo $dupCount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment