This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Control Flow: Switch Forum

View Course » View Exercise

1205 points
0185db326392ea69fa3c75ef1f496903?s=140&d=retro
Submitted by
Paul Harmer
over 4 years ago

Program took too long to finish...restarting

Tried changing the { to a :
Then changing the } to endswitch;
Go the error message "Program took too long to finish...restarting"
switch ($i):
case 0:
echo '$i is 0.';
break;
case 1:
case 2:
case 3:
case 4:
case 5:
echo '$i is somewhere between 1 and 5.';
break;
case 6:
case 7:
echo '$1 is either 6 or 7.';
break;
default:
echo "I don't know how much \$i is";
break;
endswitch;


2 votes

permalink

<?php
$i = 5;

switch ($i):
    case 0:
        echo '$i is 0.';
        break;
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
        echo '$i is somewhere between 1 and 5.';
        break;
    case 6:
    case 7:
        echo '$i is either 6 or 7.';
        break;
    default:
        echo "I don't know how much \$i is.";
        endswitch;

?>

Try to use it.

861 points
5225c4e1abf821eb75006519_81510258
Submitted by
Renan Zapelini
almost 4 years ago

1 Comment

548473d386f552262a000e72_412782804 Kingsley almost 3 years ago

worked


1 vote

permalink

The code itself is fine, but the restarting is a issue within Codecademy's systems, usually it works after you resubmit it.

504 points
2b153953ef015ea1708bd5f306bd2bb6?s=140&d=retro
Submitted by
Roni
over 4 years ago

2 Comments

0185db326392ea69fa3c75ef1f496903?s=140&d=retro Paul Harmer over 4 years ago

Thanks, yeah things are 'playing up' at the moment. Thought I'd leave it & try again today. Eventually got a pass after 5 submits! Now stuck on the next exercise & getting the message "Disconnected. Please try again." Have been really impressed with Codecademy so far with the odd hiccup, but now it's starting to get annoying!

51a619337a3995e33b004917_525833968 Chanaka Ruwan about 4 years ago

i also have that problem.


0 votes

permalink

<!DOCTYPE html>





<?php
$i = 5;

switch ($i): 
    case 0:
        echo '$i is 0.';
        break;
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
        echo '$i is somewhere between 1 and 5.';
        break;
    case 6:
    case 7:
        echo '$i is either 6 or 7.';
        break;
    default:
        echo "I don't know how much \$i is.";
endswitch;
?>
</body>

1246 points
55c7afa2937676dc6a000065_90077525
Submitted by
Alejandro
about 2 years ago