Dan array. Remove from the array all elements that occur more than 2 times. Delete the elements, but instead of them (deleted elements) appear zeros, how to get rid of them?
$arr=[5,0,5,9,-3,4,0,5,6,7,8,-9,0]; $count = 0; $n=count($arr); for ( $i = 0; $i < $n; $i++) { for ( $j = 0; $j < $n; $j++) { if($arr[$i] == $arr[$j]) { $count++; $a=$j; } } if($count >= 2) { for ($j = $a; $j < $n-1; $j++) { $arr[$j] = $arr[$j+1]; } $n--; for ($j = $i; $j < count($arr)-1; $j++) { $arr[$j] = $arr[$j+1]; } $arr--; } $count = 0; } for ( $i = 0; $i < count($arr); $i++) { echo $arr[$i]." "; }
не менее- splash58более 2 раз- 2 not included :) - splash58