Putting it All Together


      // On the line below, create your own associative array:
      $myArray = array("Pero", "Ivo");
      echo $myArray[0];
      foreach ($myArray as $keys) {
      echo '<br>' . $keys;
      // On the line below, output one of the values to the page:
      // On the line below, loop through the array and output
      // *all* of the values to the page:

I passed this, but comments and instructions want me to do different things. Why is that so?
Hint said use for loop with count function, I did it with foreach loop and without count. Is my method legit?
- Create a variable called $myArray and set it equal to a new array that you create, which can contain any items you like.
- Grab a value from your array and display it.
- Now loop through the array and output the contents to the browser!


Most of the times
there is more than one way to solve a given problem......

In the PHP course they try to lead you through several possible solutuions....

Using google search
have a read through
for loop site:php.net/manual/en


Can you take a screenshot of how everything looks in coding environment on Codecademy?

Your code works fine but no matter how clever, how good your code is you have to do exactly what instructions tell you. Try for loop and see if it works, and your array isn't associative array but I'm not sure if that's what instructions ask you to do, because looping through associative array using for loop wouldn't be really convenient way.


my code works fine and I did everything but they are giving the hint to use count with for loop, I did instead foreach without count and got the same result, I understand everything but my question was just is my code legit or I'm missing something

you have everything in first post comments and instructions


As I said your code works fine, but you have to use for loop and foreach if you want to pass that exercise. There are many solutions to solve a problem. Have you passed that exercise?


I did with just foreach


Cool, I thought your code won't pass because sometimes instructions tell you strictly to use one particular technique.