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

Arrays Forum

View Course

591 points
575728474b7f51faae0002e6_58464479
Submitted by
Buwaneka De Silva
over 2 years ago

Help!!Arrays 3/7

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

Oops, try again. Did you create an array called $friends? Error shown...


1 vote

permalink

You have to call you array $friends instead of $arrayfriends because the scripts check for existance of that particular array with at least 3 strings. Also, I have come to a problem when one of your strings consists of a non standard english character like "Željko" which is common Croatian name. So you still get an error even if everything is OK.

63 points
15c2c0a95267d8076341e1748c96b1dd?s=140&d=retro
Submitted by
Domagoj Kučko
over 2 years ago

1 Comment

575728474b7f51faae0002e6_58464479 Buwaneka De Silva over 2 years ago

Thanks! :)


1 vote

permalink

What am I doing wrong here?

$friends = array("Friend 1", "Friend 2", "Friend 3", "Friend 4");

Error telling me to remember to put in three elements, and stings in quotes.

928 points
8b1b3bde6f80b171243fb43f626cd5c4?s=140&d=retro
Submitted by
cyberninja1
over 2 years ago

5 Comments

15c2c0a95267d8076341e1748c96b1dd?s=140&d=retro Domagoj Kučko over 2 years ago

Spaces are probably causing errors. Try putting "Friend1" etc.

92410b3ad1740b0ed00fec6a3f181476?s=140&d=retro Neel Shivdasani over 2 years ago

I copied the exact array that was used in the previous example to make sure that my syntax was right, and I am getting the error about having at least 3 elements.
$friends = array("Egg", "Tomato", "Beans","Chips","Sausage" );

575728474b7f51faae0002e6_58464479 Buwaneka De Silva over 2 years ago

Stick to 3 element and try again it might work...

Picture Kristen Marie over 2 years ago

Yeah, it just wants three elements and not more than three even though it says to put at least three elements.

041270520710f71d90aa125baffad434?s=140&d=retro luis_francisco_c about 2 years ago

the error you have it in the last space... this example is fine: $friends = array("Peter", "Frank", "Oscar" );