-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