1. Home
  2. Php
  3. Match

Match keyword with the values. This is a new feature in PHP8.

#php#php8
$language_code = "en";

$language = match ($language_code){
    'en' => 'English',
    'es' => 'Spanish',
    'fr' => 'French'
}

echo $language; // returns 'English'
copy
Full Php cheatsheet