<?php
//Set up the base vars
$sceneCount=23;
$currentScene=1;
$brainBlownCounter=0;
//Assemble the scenes
while($currentScene <= $sceneCount)
{
$scenes[] = 'Scene '.$currentScene;
}
//Make this film special
array_reverse($scenes);
//Play
$sceneCounter =0;
foreach ($scene as $somethingThatHappened)
{
$sceneCounter++;
$leonardsMemory = $somethingThatHappened;
echo ('We see '.$somethingThatHappened.'<br />');
echo ('Your brain is now '.(($sceneCounter / count($scenes) * 100)).'% blown.<br /><br />';
$leonardsMemory=NULL;
}
//TODO: Remember Stanley Ipkiss
?>
有人能发现此代码中的任何问题吗?
while循环不应该正常运行,没有任何输出!
由于
答案 0 :(得分:2)
增加currentScene的值
while($currentScene <= $sceneCount)
{
$scenes[] = 'Scene '.$currentScene;
$currentScene++;
}
和
更改此
foreach ($scene as $somethingThatHappened)
要
foreach ($scenes as $somethingThatHappened)
答案 1 :(得分:1)
此:
while($currentScene <= $sceneCount)
{
$scenes[] = 'Scene '.$currentScene;
}
$currentScene
和$sceneCount
都不会更改。
答案 2 :(得分:0)
问题在于:
while($currentScene <= $sceneCount)
{
---> $scenes[] = 'Scene '.$currentScene;
}
添加$currentScene++
以移至下一个值。