I want to output Java instead of PHP. Please help


#1

I do not understand what am I doing wrong. I want to output Java instead of PHP. Please help. Below is my code:






<?php
$languages = array("HTML/CSS",
"JavaScript", "PHP", "Python", "Ruby");
// Write the code to modify
// the $languages array!
echo $languages[2];
$languages[2]="Java";
echo $mylangauges[2];
?>




#2

Hope this will help

<?php
    $languages = array("HTML/CSS", "JavaScript", "PHP", "Python", "Ruby");
    
    // Write the code to modify
    // the $languages array!
   $languages[1] = "Java";
   echo $languages[1]; 
?>

The codes above will output Java. Remember, array holds multiple value and starts with 0. meaning:

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

is equal to

  $languages = array(0, 1, 2, 3, 4)

And one more thing, you echoed variable $mylangauges which is undefined. You should echo the variable that holds your array. use the variable $languages instead.


#3

If you are trying to modify JavaScript to become Java...remember that array indexes begin with 0, not 1. So $languages[1] is the JavaScript, not $languages[2]

[0] = HTML/CSS
[1] = JAVASCRIPT
[2] = PHP
....ETC.


#4

Thank you, this helps a lot.