Array Functions I


#1


https://www.codecademy.com/pt/courses/web-beginner-en-7I7Xm/0/6?curriculum_id=5124ef4c78d510dd89003eb8#

Ops, tente outra vez. The printed output should be an integer.


Replace this line with your code. 

array_push($variavel_Nomes, "Miguel");
array_push($variavel_Nomes, "Beatriz");
array_push($variavel_Nomes, "Margarida");
array_push($variavel_Nomes, "Rita");
array_push($variavel_Nomes, "Eduardo");
array_push($variavel_Nomes, "Tomás");

print count( $variavel_Nomes );

What is wrong with my code?


#2

Hi
didn't you forget to create the array $variavel_Nomes before pushing elements in it?
When I copy/paste your code and add the creation of the array, your code works perfect for me and prints 6
Cheerio


#3

<?php

$variavel_Nomes = array();

array_push($variavel_Nomes, "Miguel");
array_push($variavel_Nomes, "Beatriz");
array_push($variavel_Nomes, "Margarida");
array_push($variavel_Nomes, "Rita");
array_push($variavel_Nomes, "Eduardo");
array_push($variavel_Nomes, "Tomás");

print count( $variavel_Nomes );
?>

Sorry, this is my real code and the same error...


#4

Mmm I copied/paste your code and it is working in my browser. Two ideas that may help :

1) replace "Tomás" by "Tomas", maybe the special character is not well appreciated by your browser.

2) delete your browser recent history/cookies and try it again.

Otherwise I can not help you further
Cheerio


#5

Thanks for your help. I made the suggested changes , tried in chrome and mozila and did not work. I am stuck, can not move forward on the course.