|
Chapter 6
Storing Data in Groups
by Using Arrays
In This Chapter
Building arrays
Assigning values to arrays
Sorting arrays
Using values in arrays
Building multidimensional arrays
A
rraysare complex variables that store a group of values under a single
variable name. An array is useful for storing a group of related values.
For example, you can store information about a car, such as model, color, and
cost, in a single array named
$FordInfo
. Information in an array can be han-
dled, accessed, and modified easily. For example, PHP has several methods
for sorting the information inside an array.
In this chapter, you find out how to create, modify, copy, and use arrays.
Creating and Working with Arrays
Arrays are an important feature in PHP programming. This section describes
how to create, modify, and remove arrays.
Creating arrays
To create a variable, you assign a value to it. Similarly, the simplest way to
create an array is to assign a value to it. For instance, assuming that you have
not referenced
$customers
at any earlier point in the script, the following
statement creates an array called
$customers
:
|