PHP match Expression Last Updated : 31 Aug, 2022 Comments Improve Suggest changes Like Article Like Report The PHP match expression is used for the identity check of a value. It is similar to the switch statement i.e. it matches the expression with its alternative values. The match expressions are available in PHP 8.0.0. The match expression compares the value using a strict comparison operator (===) whereas the switch statement uses a loose comparison operator (==). Syntax: return_value = match(expr) { key1 => val1, key2 => val2, ... } Note: The match expression must be ended with semicolons. Example 1: The following code demonstrates the match expression in PHP. PHP <?php $sub = 'PHP'; $val = match ($sub) { 'HTML' => 'HTML Course', 'CSS' => 'CSS Course', 'PHP' => 'PHP Course', 'JavaScript' => 'JS Course', 'WebDev' => 'Complete Web Development' }; var_dump($val); ?> Output: string(10) "PHP Course" Example 2: The following code is another example of a PHP match expression. PHP <?php $marks = 78; $res = match (true) { $marks < 33 => 'Fail', $marks < 45 => 'Third Division', $marks < 60 => 'Second Division', $marks < 75 => 'First Division', $marks <= 100 => 'Distinction' }; var_dump($res); ?> Output: string(11) "Distinction" Reference: https://www.php.net/manual/en/control-structures.match.php Comment More infoAdvertise with us Next Article PHP match Expression V vkash8574 Follow Improve Article Tags : Web Technologies PHP PHP-Control-Statement Similar Reads PHP | Regular Expressions Regular expressions commonly known as a regex (regexes) are a sequence of characters describing a special search pattern in the form of text string. They are basically used in programming world algorithms for matching some loosely defined patterns to achieve some relevant tasks. Some times regexes a 12 min read PHP Math Functions PHP is a scripting language that comes with many built-in math functions and constants. These tools help you do basic math, solve more complex problems, and work with different math concepts. This guide gives an overview of PHP's math functions and constants, along with examples, practical uses, and 5 min read PHP | Decision Making Decision-making is an important part of programming, allowing the program to execute different actions based on conditions. In PHP, decision-making helps control the flow of a program by executing different blocks of code depending on certain conditions or expressions. PHP provides several construct 5 min read PHP | preg_match() Function This function searches string for pattern, returns true if pattern exists, otherwise returns false. Usually search starts from beginning of subject string. The optional parameter offset is used to specify the position from where to start the search. Syntax: int preg_match( $pattern, $input, $matches 2 min read PHP max() Function The max() function is an inbuilt function in PHP, used to find the numerically maximum value in an array or the numerically maximum value of several specified values. Syntaxmax(array_values) or max(value1, value2, ...)ParametersThis function accepts two different types of arguments which are explain 2 min read Like