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

Arrays Forum

View Course

582 points
Picture
Submitted by
Tyler Batdorf
about 2 years ago

PHP Arrays 7/7

When I copy and paste the code from the exercise into a file and save it as exercise.php then open it in chrome, it shows this on the page:

$lang

"; } ?>

Why is it not showing the same result as the exercise?
Here's the code:

<html>
    <head>
        <title>Modifying Elements</title>
    </head>
    <body>
        <p>
            <?php
                $languages = array("HTML/CSS",
                "JavaScript", "PHP", "Python", "Ruby");
                unset($languages[3]);
                foreach($languages as $lang) {
                    print "<p>$lang</p>";
                }
            ?>
        </p>
    </body>
</html>

1 vote

permalink

Do you have install php locally?

243 points
52b80f320f60b4f987bc81c86051c6d0?s=140&d=retro
Submitted by
Piotr
about 2 years ago

1 Comment

Picture Tyler Batdorf about 2 years ago

OH my goodness, I'm so dumb. I realize what's going on now. The code runs on the server, not locally, so you can't just open a .php file in a browser and expect it to work. Thank you!