【发布时间】:2017-06-17 17:22:34
【问题描述】:
如何以简单的方式检查 5 个变量是否相同?
这是我的示例代码:-
$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";
}
有没有人可以帮助我?...
【问题讨论】:
-
if(count(array_unique($checkcommon)) ==1){echo "all values are same";}