DEV Community

loading...

Discussion on: PHP 8 features I wish also existed in JavaScript

Collapse
devmount profile image
Andreas Author • Edited

match has a default case too. Also, you can comma-separate multiple values:

$fontWeight = match ($weight) {
  100, 200 => "Super Thin",
  300 => "Thin",
  400, 500 => "Normal",
  600, 700, 800 => "Bold",
  900 => "Heavy",
  default => "Not valid"
};
Enter fullscreen mode Exit fullscreen mode

Edited the example in the article accordingly.