I am dynamically trying to populate a multidimensional array and having some trouble.
I have a list of US states. Associative array like this $states[nc], $states[sc
To add an element, use empty brackets.
foreach($states as $state) {
foreach($cities as $city) {
$data[$state][] = $city;
}
}
This will create an array like this
array(
'nc' => array('city1', 'city2', ...),
'sc' => array('city1', 'city2', ...)
)
See manual under "Creating/modifying with square bracket syntax"