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

Arrays Forum

View Course » View Exercise

211 points
8fdd5885c33e9d0400982ce22fcb02f7?s=140&d=retro
Submitted by
Shill76
almost 3 years ago

Output is showing both the original and new value

Seem to get the output as PHPtest with the code below, any ideas?

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

    echo $languages[2];

    $languages[2] = "test";
    echo $languages[2];


    // Write the code to modify
    // the $languages array!

  ?>

2 votes

permalink

Oh wait i have an answer. You wrote echo twice: before and after the value was changed. Just delete the first line: echo $languages[2]

177 points
29b6a3c43778050cd3e6c26e97c69f01?s=140&d=retro
Submitted by
DinaDi
over 2 years ago


0 votes

permalink

nevermind, I'm an eegit - was printing out 2 lines

211 points
8fdd5885c33e9d0400982ce22fcb02f7?s=140&d=retro
Submitted by
Shill76
almost 3 years ago


0 votes

permalink

I have the same problem. So i suppouse it just means that the old value is not replaced with this method.

177 points
29b6a3c43778050cd3e6c26e97c69f01?s=140&d=retro
Submitted by
DinaDi
over 2 years ago


0 votes

permalink

Actually the instructions on 'Modifying Array Elements’ don’t tell us to delete the first ‘echo.’ It’s cadecademy fault for beginners like us who easily get lost. But thanks for the tips guys!

1044 points
55de654ce39efe9a4a000717_225845417
Submitted by
Fundi
about 2 years ago