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 trialJaime Rios
Courses Plus Student 21,100 PointsAbout the arrays.
Is it best practice to write arrays like Hampton does in the video or should I be writing them in a single line. ie
$cars = array("Volvo", "BMW", "Toyota");
2 Answers
Ted Sumner
Courses Plus Student 17,967 PointsI think it is better to write vertically like Hampton does. It is far easier to see what is going on, especially when they get large. But I also think you will find that you don't actually write them much in real life. You use them to store data, but it will usually come from some other place like a database or developed in code through loops where the key is stepped through without being hard coded in advance.
jason chan
31,009 Pointsit's really up to you and how easy it is for you to dubug.
Jaime Rios
Courses Plus Student 21,100 PointsJaime Rios
Courses Plus Student 21,100 PointsShould I do the same in JavaScript?
Ted Sumner
Courses Plus Student 17,967 PointsTed Sumner
Courses Plus Student 17,967 PointsYes. All the languages I have seen are formatted vertically.