The associative array -- an indispensable data type used to
describe a collection of unique keys and associated values -- is
a mainstay of all programming languages, PHP included. In fact,
associative arrays are so central to the task of Web development
that PHP supports dozens of functions and other features capable
of manipulating array data in every conceivable manner. Such
extensive support can be a bit overwhelming to developers
seeking the most effective way to manipulate arrays within their
applications. In this article, I'll offer 10 tips that can help
you shred, slice and dice your data in countless ways. 1. Adding
Array Elements PHP is a weakly typed language, meaning you're
not required to explicitly declare an array nor its size.
Instead you can both declare and populate the array
simultaneously: Additional array elements can be appended like
this: $capitals['Arkansas'] = 'Little Rock'; If you're dealing
with numerically indexed arrays and would rather prepend and
append elements using an explicit