-2
当我打印出整数(1或0)时,所有迭代(在这种情况下有3个)会打印出正确的数字。第一个和第二个返回1,最后一个返回零。但是,'如果'陈述似乎无论如何显示的一切。我究竟做错了什么?'IF'陈述无效?
以下所有代码都位于较大的'for'循环中。
$yn = 0;
if(!in_array($pos, $blocks)){
$blocks[$x] = $pos;
$x++;
$yn = 1;
}
print_r($blocks);
print "YN: ".$yn; # this prints out 1, 1 and 0 on the last iteration
if(yn){
# show some stuff (is displayed in all three iterations, but it shouldn't be on the last)
}
您忘记了$ if if($ yn) – uzyn 2012-07-23 17:00:43
请确保您在发布之前没有语法错误,并且说某件事情“无法正常工作” – haynar 2012-07-23 17:02:36
谢谢,我是盲目的。 – trainoasis 2012-07-23 17:03:26