php if 判斷 可以改一次全部一次改嗎

$top_b_url=$_SERVER['PHP_SELF'];

$top_b_array=array("/about/who-we-are.php","/about/about-us.php","/about/what-we-believe.php","/about/founders.php","/about/what-we-do.php","/users/active.php","/users/signup_done.php");
foreach($top_b_array as $x_value)
{
if ($top_b_url==$x_value)
{
echo '2';
break;
}
}
這樣可以正常顯示2(若陣列有符合)
但若這樣
foreach($top_b_array as $x_value)
{
if ($top_b_url==$x_value)
{
echo '2';
break;
}
else
{
echo 'f';
break;
}
}


這樣會顯示2f

找不到問題
標籤:

評論

Sign In or Register to comment.