function calculateEvenNumbers(array $numbers): int { $count = 0; foreach ($numbers as $number) { if ($number % 2 === 0) { $count++; } } return $count; }
- function calculateEvenNumbers(array $numbers): int {
$result = [];- $count = 0;
- foreach ($numbers as $number) {
- if ($number % 2 === 0) {
$result[] = $number;- $count++;
- }
- }
return count($result);- return $count;
- }