Array Functions I


#1

What is wrong with mine?



<?php
$fav_bands = array();

array_push($fav_bands, "Turtle";
array_push($fav_bands, "Deer";
array_push($fav_bands, "Dog";
array_push($fav_bands, "Cat";
array_push($fav_bands, "Mouse";

print count($fav_bands);

?>
</p>

It says, "Oops, try again. The printed output should be an integer."


#2

Here try this

<?php
$fav_bands = array();
// you forgot to close the method calls with ')'
array_push($fav_bands, "Turtle");
array_push($fav_bands, "Deer");
array_push($fav_bands, "Dog");
array_push($fav_bands, "Cat");
array_push($fav_bands, "Mouse");

print count($fav_bands);

?>
</p>

#3

Hi, i have a problem with this exercise too, i just copy paste ur code and it says "Oops, try again.
The printed output should be an integer." So i don't know where is the problem ?


#4

it should work i just tested it


#5

Still doesn't work :confused:


#6

Have you figured it out yet?? Mine worked. Here is my coding:



<?php
// Create an array and push 5 elements on to it, then
// print the number of elements in your array to the screen
$fav_bands = array(10);
array_push($fav_bands, "Asking Alexandria");
array_push($fav_bands, "Tom Petty");
array_push($fav_bands, "Bro Safari");
array_push($fav_bands, "Bring Me The Horizon");
array_push($fav_bands, "Beartooth");
print count($fav_bands); // prints 5
?>



#7

This work for me:
<?php
$fav_bands = array();
array_push($fav_bands, "Maroon 5");
array_push($fav_bands, "Bruno Mars");
array_push($fav_bands, "Nickelback");
array_push($fav_bands, "Katy Perry");
array_push($fav_bands, "Macklemore");
print count($fav_bands); // prints 5
?>