0

just started learning PHP. I'm just trying to write something that will roll a die until you roll a 6 and return how many rolls it took. Not really sure what I am doing here wrong. It returns - Parse error: syntax error, unexpected $end in /Applications/AMPPS/www/test.php on line 46

<?php
     $rollCount = 0;
    do {
        $roll = rand(1,6);
        $rollCount ++;
        switch(5){
        case 0:
        echo "1";
        break;
        case 1:
        echo "2";
        break;
        case 2:
        echo "3";
        break;
        case 3:
        echo "4";
        break;
        case 4:
        echo "5";
        break;
        case 5:
        echo "6";
        break;

    }
    while($roll);
    $verb = "were";
    $last = "rolls";
    if($rollCount == 1){
        $verb = "was";
        $last = "roll";
    }
    echo "<p> There {$verb} {$rollCount} {$last}!!!";

?>

Please explain.

  • 1
    Take some time to indent your code properly. You'll quickly see that you're missing a closing `}` –  Jul 01 '15 at 23:57
  • using a good IDE would also help in your learning –  Jul 01 '15 at 23:58

0 Answers0