No, it is seeing '$year' as an associative index, because of the single quotes. Leave off quote marks altogether if you want the variable name expanded to its value. It will then be either associative or numeric, depending on how you define $year. (You could use double quotes, but they are unnecessary here.)
Understanding the differences among using single quotes, double quotes, and no quotes is pretty basic to using PHP, so you should read this.