Modifying Array Elements


#1

The question has asked to change one of the items from an array list. It seems that when I try to change item 2 it does not change the item, rather adds to it. In the code below my item 2 is PHP, instead of replacing PHP with java it adds java to PHP , like this, output: "PHPjava". Please take a look at the code below:


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

$languages[2] = "java"; 

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

// outputs "PHPjava"


#2

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