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

banner
Close banner
0 points
Submitted by Aniket Verma
over 9 years

Why wont this work??Always shows some error like did you replace [ ] with {} when i already have

Answer 53fac56780ff337ac7008734

4 votes

Permalink

You have a space after {2} take that space out and put ; right after {2}. It will work. <?php $tens = array(10, 20, 30, 40, 50); echo $tens{2};

  ?>
points
Submitted by Ellie Adam
over 9 years

Answer 5413c3547c82caa4ba001a7f

0 votes

Permalink

You need to put {2} in normal braces, like [2].

points
Submitted by Smash Boss
over 9 years

Answer 542c596d7c82caee44001360

0 votes

Permalink

Insert a space after [2] eg: echo $tens[2] ;

points
Submitted by menaka.siri
over 9 years

Answer 54652de752f863df91000100

0 votes

Permalink

Very contradicting answers here. Fact 1: While using arrays, to access the index of the value, you type $arrayName[i] with i being the index position - 0 to however many items you have.

Fact 2: White space rarely matters and when it does, the accompanying code documentation will usually warn you of it. So, both $tens[2]; and $tens[2] ; and even $tens[2] ; will work just fine

points
Submitted by smartalec
over 9 years

Answer 546dd27b282ae3655a00156b

0 votes

Permalink

I noticed the example shows print instead of echo, even though the previous exercise had you use echo. I had to change not just the braces, but echo to print as well.

points
Submitted by tpiecora
over 9 years