foreach($arr as $key) { if ($key == $valor) { $cont++; } if ($count > 2) { return true; } else { return false; } }