For an aide to my example, here is an array of names grouped by street and house numbers.
Code: Select all
$occupants_by_address = array (
'30th Street' => array (
'Number 13' => 'Bill Jones',
'Number 25' => 'Portia Caine',
),
'42nd Street' => array (
'Number 13' => 'Amanda Howard',
'Number 7' => 'Bryce Hardin',
),
);
You can ask the question "Who lives on 30th Street at Number 13?" In code, the question would be represented as
Code: Select all
echo $occupants_by_address['30th Street']['Number 13']; // Bill Jones
The answer would be Bill Jones.
However, the question "Who lives at Number 13?" is unanswerable because no street was specified.
Code: Select all
echo $occupants_by_address[]['Number 13']; // Wrong - no street specified
Both Bill Jones and Amanda Howard live at Number 13, but it's not the same Number 13 because the streets are different.
If you want a better answer, you will have to show us more code or further explain what your code is supposed to do.