$c['paid_count'] == $min_paid); $birthday_eligible = []; $others = []; foreach ($eligible as $c) { $is_birthday_payer_eligible = ( !empty($c['birthday']) && $c['birthday'] !== '0000-00-00' && $c['last_birthday_year'] != $current_year ); if ($is_birthday_payer_eligible) { $birthday_eligible[] = $c; } else { $others[] = $c; } } // Sortiere alphabetisch $sort = fn($a, $b) => strcmp($a['username'], $b['username']); if (!empty($birthday_eligible)) { usort($birthday_eligible, $sort); return $birthday_eligible[0]['username']; } $all = array_merge($birthday_eligible, $others); usort($all, $sort); return $all[0]['username']; }