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 trial

PHP PHP Functions Introducing Functions PHP Function Default Arguments

Jaime Rios
PLUS
Jaime Rios
Courses Plus Student 21,100 Points

About 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

I 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.

Yes. All the languages I have seen are formatted vertically.

jason chan
jason chan
31,009 Points

it's really up to you and how easy it is for you to dubug.