PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $seq = [20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5]; function findIt(array $seq) { $arr = array_count_values($seq); $el = []; foreach($arr as $a){ if($a >= 1 && $a % 2){ $el[] = $a; } } $res = array_keys(array_filter($arr, $el)); return $res; } print_r(findIt($seq));
Show:  
Copy Clear