From the course: Learning PHP

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

What are arrays and how do they work?

What are arrays and how do they work? - PHP Tutorial

From the course: Learning PHP

Start my 1-month free trial

What are arrays and how do they work?

- [Instructor] Arrays are a bit different from the rest of our variables. Arrays act as key-value pairs that essentially function as a set of variables, so this allows us to make a list of related items that we can reference as one big variable. The benefit of organizing data this way is it's easier to manage when we're working with related values or complex data sets, like when retrieving information from a database. Array values can be any of the data types that standard variables can be, and we can mix them. So we can have an array that includes strings only, an array that includes integers only, or an array that includes integers, strings, characters, or anything else you can think of. There are two types of arrays you should know about, indexable arrays, which use numbered keys, and associative arrays, which use strings as keys. You'll learn how to define each of those in PHP later but for now, let's learn a little bit…

Contents