switch statement with two variables at a time

后端 未结 6 1692

Could someone suggest the best way to have the following switch statement? I don\'t know that it\'s possible to compare two values at once, but this would be ideal:

6条回答
  •  心在旅途
    2020-12-09 05:13

    Doesn't work. You could hack around it with some string concatentation:

    switch($color . $size) {
       case 'bluesmall': ...
       case 'redlarge': ...
    }
    

    but that gets ugly pretty quick.

提交回复
热议问题