S
Seoffix.com
Sign In Get Pro Membership

PHP 8 Server-Side

PHP 8.2: Modern Match Expressions & Array Mapping

Intermediate PHP 25 XP

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

 = 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.

Hints

  1. strtolower() ensures case-insensitivity
  2. match returns the expression value directly
  3. Provide a default fallback branch

Your answer

This lesson is checked against the lesson rules. Your code is never run on our servers.

AI Code Explainer & Translator

Runs without any outside service.
 
Mark Complete & Earn XP
Earn 25 XP. Finish every lesson in the track to earn its certificate.
Sign in to earn XP