Forever Loading


#1


I've got a problem on For Loops in PHP.


When I open this lesson, I get a loading wheel that spins forever—I can't even edit my code. It seems like a bug to me.


#2

The problem might be because of an infinite loop. Sometimes not setting the condition properly inside the for loop results in running the loop infinite times thereby crashing the browser or loading endlessly. Since you haven't pasted your code, here is the solution that I used,

<html>
  <head>
    <link rel="stylesheet" href="stylesheet.css" />
    <title>Codecademy Languages</title>
  </head>
  <body>
    <h1>Languages you can learn on Codecademy:</h1>
    <div class="wrapper">
      <ul>
        <?php
          $langs = array("JavaScript",
          "HTML/CSS", "PHP",
          "Python", "Ruby");
        
          foreach ($langs as $lang) {
              echo "<li>$lang</li>";
          }
        
          unset($lang);
        ?>
      </ul>
    </div>
  </body>
</html>

foreach is an enhanced forloop in PHP

hope that helps


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.