Arrays 5 access by offset with {} bug


box on right prints the following:

instead of it printing 30 as the instruction suggests

the lesson is to replace the [] with {} which i did, however it does not print what it should (it should simply print "30"). it only works when the echo on line 9 is typed as:
echo "$tens[2]";
even though the instruction asks you to replace the brackets with {}, however this does not work and does not allow you to pass the current lesson.

    <title>Accessing Elements</title>
        $tens = array(10, 20, 30, 40, 50);
        echo "$tens{2}";
// due to the {} replacing [] it now gives an error


you shouldn't use quotation marks (") this will make it a string and simply echo $tens{2}

in php to access items of an array by index use {}, not []


right i see, i just made it print $tens{2};


well done :slight_smile: