Modifying Array Elements Two Outputs


#1







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

    echo $languages{4};
    //prints "Ruby"
    $languages[4] = "Python";

    echo $languages{4};
    //prints "RubyPython" why?

  ?>
</p>


I don't know why the outcome is coming out with 2 names. I tried sending the whole code through but it only allowed the main important part into the question.


#2

you modify and access elementsof the array with square brackets:

$languages[4] = "Python";
 echo $languages[4];

#3

I changed them all to be the same symbols and tried and changed them around but it still outputs "RubyPython". I tried to change the numbers but it just changes the output word/words.


#4

The answer was to remove the first echo line and it cancels out the problem.