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.
Latest posts by Jamie (see all)
- How To Find Out What WordPress Theme A Site is Using - October 16, 2018
- The Most Popular Blog Types – 2018 Edtion - October 12, 2018
- Best Affiliate Marketing Platforms (2018) - October 7, 2018