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

Why we would use empty array?

Most of the time when I see other code, I found they had used empty array, what is the point of the such empty array in php?

1 Answer

Abraham Juliot
Abraham Juliot
47,353 Points

Arrays are often declared empty and then later assigned data from user input or functions. Think of an empty array as an empty list which may conditionally contain items.