0
<?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
?>

Can anyone spot any problems in this code?

The while loop isnt acting as it should be and nothing gets outputted!

Thanks

1
  • -1??? why the vote down? Commented May 17, 2011 at 17:17

3 Answers 3

2

Increment the value of currentScene

while($currentScene <= $sceneCount)
{
    $scenes[] = 'Scene '.$currentScene;
    $currentScene++;
}

and

Change this

foreach ($scene as $somethingThatHappened)

To

foreach ($scenes as $somethingThatHappened)
Sign up to request clarification or add additional context in comments.

Comments

1

This:

while($currentScene <= $sceneCount)
{
    $scenes[] = 'Scene '.$currentScene;
}

Both $currentScene and $sceneCount are not changed.

Comments

0

The problem is here:

while($currentScene <= $sceneCount)
{
--->    $scenes[] = 'Scene '.$currentScene;
}

add a $currentScene++ to move to the next value.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.