Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSérgio Leal
7,803 PointsShort array syntax support
When asked to create an empty array $colors
$colors = [];
the short array syntax is not accepted as a valid answer.
2 Answers
Donald Brunais
8,895 PointsIn PHP the correct syntax to make an empty array would be $colors = array(); PHP doesn't use the "[ ]" for arrays like other languages do.
Jason Anello
Courses Plus Student 94,610 PointsHi Sergio,
I don't know how the challenge works. I'm not sure if it's running the code in a live php environment but perhaps the version is lower than php 5.4 which is when that became available.
Hampton Paulk Should the challenge pass with the short array syntax?
Sérgio Leal
7,803 PointsSérgio Leal
7,803 PointsFrom PHP dpcumentation "As of PHP 5.4 you can also use the short array syntax, which replaces array() with []."