<?php
function getClassLevel($class_name) {
    $class_name_upper = strtoupper($class_name);
    
    // Check for S5-6 (A-Level)
    if (preg_match('/SENIOR\s*[56]|S\.?[56]\b|ALEVEL|A-LEVEL/i', $class_name_upper)) {
        return 'senior_level';
    }
    
    // Check for S3-4 (O-Level)
    if (preg_match('/SENIOR\s*[34]|S\.?[34]\b/i', $class_name_upper)) {
        return 'senior_olevel';
    }
    
    // Default to S1-2 (Lower levels)
    return 'lower_level';
}

// Test cases based on your data
echo "=== CLASS LEVEL MAPPING TEST ===\n\n";

$test_cases = [
    "SENIOR 5",
    "SENIOR 4", 
    "SENIOR 3",
    "S5",
    "S4",
    "S3"
];

foreach ($test_cases as $class_name) {
    $result = getClassLevel($class_name);
    echo "Class: '{$class_name}' -> '{$result}'\n";
    
    // Check if it would trigger the ranking condition
    $would_trigger_ranking = ($result === 'senior_level');
    echo "Would trigger ranking? " . ($would_trigger_ranking ? "YES" : "NO") . "\n\n";
}
?>