fork download
  1. <?php
  2.  
  3. $re = '/(?J)(?:,\s?min\s?(?P<min>\d+)\s?)(?:,\s?max\s?(?P<max>\d+)\s?)?|(?:,\s?max\s?(?P<max>\d+)\s?)(?:,\s?min\s?(?P<min>\d+)\s?)?/';
  4. if (preg_match($re, ",max 1, min 2", $matches)){
  5. print_r($matches["max"] . " = max and min = " . $matches["min"] . PHP_EOL);
  6. }
  7. if (preg_match($re, ",min 5, max 6", $matches)){
  8. print_r($matches["max"] . " = max and min = " . $matches["min"] . PHP_EOL);
  9. }
  10. if (preg_match($re, ", min 7", $matches)){
  11. print_r($matches["max"] . " = max and min = " . $matches["min"] . PHP_EOL);
  12. }
  13. if (preg_match($re, ",max 8", $matches)){
  14. print_r($matches["max"] . " = max and min = " . $matches["min"]);
  15. }
Success #stdin #stdout #stderr 0.02s 52432KB
stdin
Standard input is empty
stdout
1 = max and min = 2
6 = max and min = 5
 = max and min = 7
8 = max and min = 
stderr
PHP Notice:  Undefined index: max in /home/NXm1Ij/prog.php on line 11