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

Arrays Forum

View Course » View Exercise

1011 points
6e09362e1bfe3e7dc2f1e6d654043abe?s=140&d=retro
Submitted by
mmm1928_53054fc07c82ca4bf10014f0_del
about 3 years ago

What did I do wrong???

Modifying Elements



<?php
$languages = array("HTML/CSS",
"JavaScript", "PHP", "Python", "Ruby");

    // Write the code to modify
    // the $languages array!
    echo $languages[2];
    $languages[2]="C++";
    echo $languages[2];
  ?>
</p>

4 votes

permalink

This is the only line you have to write.

echo $languages[0] = "Java";

You are changing the item in position "0" and echoing it at the same time.

101 points
192e4836719269800fcf2a130bddbf0a?s=140&d=retro
Submitted by
didierco
about 3 years ago


3 votes

permalink

<?php
$languages = array("HTML/CSS",
"JavaScript", "PHP", "Python", "Ruby");

    // Write the code to modify
    // the $languages array!
    $languages{3}="Asp net";{
    echo $languages{3};
    }

this works for me, just add curly braces to echo sentence

470 points
7de1d08630fbfa462d958d5a3a9e9322?s=140&d=retro
Submitted by
jgvillalba72
about 3 years ago


1 vote

permalink

  1. Change an item in the $languages array. You can take your pick!
  2. Then use echo to output $languages.

You need only print out the item in the array once you've changed it.
Erase your first echo statement and it should be good.

1391 points
Eb7f3ea2cd676dc153ad900535451fa3?s=140&d=retro
Submitted by
Sera
about 3 years ago

2 Comments

6e09362e1bfe3e7dc2f1e6d654043abe?s=140&d=retro mmm1928_53054fc07c82ca4bf10014f0_del about 3 years ago

thanks

7a27e0c02016d65be55806c017470da0?s=140&d=retro mohammad yaseen over 2 years ago

it was helpful for me too thnx coder


1 vote

permalink

instructions not included!

360 points
C8f5121b56e52b32153533c7acb020bd?s=140&d=retro
Submitted by
craig Shell
almost 3 years ago