Arrays


#1

Hi guys,

I am stuck on Arrays. I have copied the example but my previous selection [1] is still being outputted along with the new selection[1]. Therefore this is what's displayed in my output screen:- JavascriptCobol

It isn't clearing the first output. Here is my code:-

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

    $languages[1] = "Cobol";

    echo $languages[1];

    // Write the code to modify
    // the $languages array!

  ?>

Thanks


#2

echo prints all strings in the same line unles you use \n, so what are you seeing is the first echo output result and the second echo output result. Try to echo something before the last echo and you'll see.

And it seems that you only have to modify, not output anything, isn't it?


#3

Thank you for this, I get it now :smile: