This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Cougar-UK
over 9 years

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>

Answer 53daaca3631fe90bf00004da

1 vote

Permalink

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

points
Submitted by pipina
over 9 years

1 comments

Cougar-UK over 9 years

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

Answer 543d494a9c4e9dd32e00029b

0 votes

Permalink

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

into : $fruit = array(‘’);

and you will pass

points
Submitted by metin89
over 9 years

1 comments

melaniesazegar about 9 years

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!

Answer 5529caab51b8877138000185

0 votes

Permalink

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

points
Submitted by shaunjr224
almost 9 years