PHP
Intermediate
Estimated Duration: 15 min
PHP 8.2: Modern Match Expressions & Array Mapping
Upgrade your PHP code from legacy switch statements to modern PHP 8.2 match expressions and type-safe array operations.
Modern PHP 8.2 Match Expressions
PHP 8 introduced match, which is an expression (evaluates to a value), does strict type checking (===), and does not require break statements.
Syntax
php
= match() {
200, 201 => "Success",
404 => "Not Found",
500 => "Server Error",
default => "Unknown",
};
Your Task
Complete the getTierBadge function to map user tiers (ree, pro, enterprise) to their respective badge label using modern match.
Target Output
Professional
Need a Hint?
- strtolower() ensures case-insensitivity
- match returns the expression value directly
- Provide a default fallback branch
solution.php
Terminal Output
Ready
Click "Run Code & Test" to execute your solution.