Modifying elements



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

    echo $languages{4};

    $languages{4} = "PHP";

    echo $languages{4};


trying to change the position of elements in the array but it outputs "RubyPHP" what im i doing wrong?
ps* both used the curly braces and [ ]
some help?


The previous echo does not include a newline.

echo $languages{4}
echo "<br>"
$languages{4} = "PHP"
echo $languages{4}

However, this will result in there being two items the same. Shouldn't matter, but if you get another SCT error, change it something else, like C++.


hi i tried it and the error "Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' on line 16"

pops up any more suggestions?

ps* im a really new at this.


My bad. I left off all the semi-colons which are absolutely necessary in PHP. Was hoping you might catch that.

echo $languages{4};
echo "<br>";
$languages{4} = "PHP";
echo $languages{4};

The above is meant as an example, not a solution, and the order may be wrong.


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