What is: Array?

In general terms, an array is an ordered arrangement of separate items. In computer terms, an array is when a name is given to a collection of different data points. For example, if you are compiling a list of all the registered users on a website, you could store this data under an array called “UserNames.”

 

If you’re solely interested in administering a WordPress website, then you won’t ever have to deal with arrays. But for developers, arrays are a core part of the PHP scripting language, and arrays are always written as a variable denoted by the dollar sign (e.g. $UserNames).

 

In PHP, there are three kinds of arrays:

 

Indexed – An array based on preset values.
Associative – Arrays are generated on the fly based on values.
Multidimensional – An array containing other arrays.

 

In the example above, $UserNames would be an indexed array because it relies on preset values (i.e. every piece of data in the User Name directory). An associative array is generated on the fly such as @UserNamesBeginningWithS that creates an array automatically by sorting and identifying every user name that begins with the letter S. And a multidimensional array would be a collection of other arrays bundled into one new array.

 

Arrays are used to sort and organize data for the purpose of performing operations. For example, if you wanted to email all of your registered users, you could write some code that includes sending an individual email that is addressed to each data point listed in the $UserNames array.

 

If you’re reading through PHP code in your WordPress files or in your theme or plugins, then when you see the variable sign ($), you’re probably looking at an array. Arrays simply help developers organize and sort data more efficiently in order for software to perform an operation on those select pieces of data.

The following two tabs change content below.

Jamie Spencer

My name is Jamie Spencer and I have spent the past 10 years building money making blogs. After growing tired of the 9-5, commuting and never seeing my family I decided that I wanted to make some changes and launched my first blog. Since then I have launched lots of successful niche blogs and after selling my survivalist blog I decided to teach other people how to do the same.