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

Functions, Part I Forum

View Course » View Exercise

1158 points
52586e25f10c602aab000f94_273456774
Submitted by
Cougar-UK
almost 3 years ago

What's wrong here?

My code won't pass.

I get the following error message:

Oops, try again. Did you remember to use array() in your code?

I have clearly used array() on line 6

<html>
    <p>
    <?php
    // Create an array and push 5 elements on to it, then 
    // print the number of elements in your array to the screen
    $fruit = array();

    array_push($fruit, "Apple");
    array_push($fruit, "Banana");
    array_push($fruit, "Kiwi");
    array_push($fruit, "Grapes");
    array_push($fruit, "Oranges");

        echo count($fruit);
    ?>
    </p>
</html>

1 vote

permalink

looks good, i passed my exercise with this code,
but try it once in print instead of echo ?

84 points
53baaa25631fe9a2a2001178_821587387
Submitted by
pipina
almost 3 years ago

1 Comment

52586e25f10c602aab000f94_273456774 Cougar-UK almost 3 years ago

I actually think it's my browser. I'm having lots of issues in chrome, switched to IE (which I hate) and it passes


0 votes

permalink

You have to change :
$fruit = array();

into :
$fruit = array('');

and you will pass

482 points
07eadabb0b193edd40203c8af57c15c1?s=140&d=retro
Submitted by
metin89
over 2 years ago

1 Comment

Cc295c27f59e7a8ecc853264009c03c2?s=140&d=retro melaniesazegar about 2 years ago

I did this and it worked. Then I tried it again without the '' and that worked too for some reason. Maybe it's a browser issue. Thanks for your help!


0 votes

permalink

Just backspace and replace a letter in the word 'array'. worked for me after i reloaded the page thrice

833 points
5554dbff9376760529000042_958324988
Submitted by
shaunjr224
about 2 years ago