This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Arrays Forum

View Course » View Exercise

574 points
521fccd5548c350abe000a4c_825465024
Submitted by
Ken
over 4 years ago

Suggestion: Probably not the best example?

First of all, I'm sorry if I'm being picky. I know this PHP section was recently released and I am deeply appreciative to learn PHP from this website =).

But I just noticed this example in the section and can't help but think it's a little incorrect from what we've been taught in the previous lessons:

Finally, you can remove elements using unset:

<?php
  $array = ("red", "blue", "green");
  unset($array[3]);
?>
  1. We've been taught to put array before the list:

    $array = array("red", "blue", "green");

  2. And there isn't a fourth item in the list xD, so probably: "unset($array[2]);" would be better.

Hope this doesn't offend anyone!


1 vote

permalink

Nicely spotted! I agree.
The author himself has written here that we declare an array by using array();

2570 points
56ec11ba1ec4b00bc400069e_656519138
Submitted by
Gaurang Tandon
over 4 years ago


0 votes

permalink

Thanks - I'll let our course creators know.

978 points
51649d3b4cdb759392000d3e_193280166
Submitted by
Linda Liukas
over 4 years ago