2017-02-01 44 views
2

如何以簡單的方式檢查5個變量是否相同或不相同?檢查多個值是否相等或使用php

這裏是我的示例代碼: -

$roster_1 = $_POST['roster_1']; 
$roster_2 = $_POST['roster_2']; 
$roster_3 = $_POST['roster_3']; 
$roster_4 = $_POST['roster_4']; 
$roster_5 = $_POST['roster_5']; 

$checkcommon = array($roster_1 , $roster_2 , $roster_3 , $roster_4 , $roster_5); 

if(array_sum($checkcommon) == count($checkcommon)) 
{ 
    $errormsg = "All the same"; 
} 
else 
{ 
    $errormsg = "not the same"; 
} 

是否有任何人誰可以幫我...

+0

'if(count(array_unique($ checkcommon))== 1){echo「all values are same」;}' –

回答