PHP: Testing whether three variables are equal

前端 未结 5 2170
情歌与酒
情歌与酒 2021-02-06 21:43

I\'ve never come across this before, but how would you test whether three variables are the same? The following, obviously doesn\'t work but I can\'t think of an elegant (and co

5条回答
  •  佛祖请我去吃肉
    2021-02-06 21:57

    $values = array($select_above_average, $select_average, $select_below_average);
    
    if(count(array_unique($values)) === 1) {
        // do stuff if all elements are the same
    }
    

    Would be another way to do it.

提交回复
热议问题