What am I doing wrong?


Modifying Array Elements

I get this as output: JavaScriptJava

        $languages = array("HTML/CSS",
        "JavaScript", "PHP", "Python", "Ruby");
       echo $languages[1];
        $languages[1] = "Java";
        echo $languages[1];


what's the instruction?
what's your error massage?

also include the link that goes to the lesson


The instruction is to change an item in an array by using its position.
I want to change the item on position 1: now "Javascript" into "Java"

As output I get both: JavaScriptJava, the item "Javascript" is not replaced, the new item "Java" is added.

The error message I get is:

"Oops, try again. It looks like you printed 'JavaScript'--that's one of the original elements! Make sure to print your modified element."

Thanks for your help.


your first echo statement prints JavaScript
and second one Java

dont print first one

now tell me is it working?you didnt include any link so i cant go to the lesson


Thanks, rcodeman! That's it! Problem solved!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.