PHP -- Arrays -- Editor doesn't accept code, despite it working, and meeting the requirements. What to do?

bug-composer
php
sct

#1


I am working on: PHP Arrays part 3

https://www.codecademy.com/courses/web-beginner-en-8a35h/0/3?curriculum_id=5124ef4c78d510dd89003eb8#

The exact instructions i have are:

"Create an array called $friends and put the names of three of your friends in it. Since each friend's name is a string, make sure to write it between quotes."


Code does compile correctly, but the editor won't accept my solution. The error message it states is: "Oops, try again. Did you remember to put at least three elements in your array? Make sure each one is a string in quotes!"

I see 3 strings here clearly, and they are all wrapped in quotes so I don't know what the issue is (unless PHP has some strange regex feature that i've ran into). I'm guessing there is a subtlety i'm missing.


<html>
  <head>
    <title>My First Array</title>
  </head>
  <body>
    <p>
      <?php
        $friends = array("Matt Lee", "Mary Mercanti", "Travis Vanderstad");
      ?>
    </p>
  </body>
</html>

After some additional debugging I've concluded their grader has a flaw. Since the following DOES pass:

<html>
  <head>
    <title>My First Array</title>
  </head>
  <body>
    <p>
      <?php
        $friends = array("do", "re", "mi");
      ?>
    </p>
  </body>
</html>

It seems as soon as I introduce a space and another character the test case fails. Such as

<html>
  <head>
    <title>My First Array</title>
  </head>
  <body>
    <p>
      <?php
        $friends = array("do a", "re", "mi");
      ?>
    </p>
  </body>
</html>

#2

Lazy code checker! :slight_smile:

This old course is on the list for rewriting so there are no bug fixes being made at this time.

Good on you for troubleshooting it!


#3

@frogeyedpeas,
With a google search something to read
php array explained site:php.net
http://php.net/manual/en/function.array.php