<?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
$scen开发者_JAVA技巧eCounter =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
?>
Can anyone spot any problems in this code?
The while loop isnt acting as it should be and nothing gets outputted!
Thanks
Increment the value of currentScene
while($currentScene <= $sceneCount)
{
$scenes[] = 'Scene '.$currentScene;
$currentScene++;
}
and
Change this
foreach ($scene as $somethingThatHappened)
To
foreach ($scenes as $somethingThatHappened)
This:
while($currentScene <= $sceneCount)
{
$scenes[] = 'Scene '.$currentScene;
}
Both $currentScene
and $sceneCount
are not changed.
The problem is here:
while($currentScene <= $sceneCount)
{
---> $scenes[] = 'Scene '.$currentScene;
}
add a $currentScene++
to move to the next value.
精彩评论