Forum Moderators: coopster
Can someone explain what is going on here?
$_TEST = array();
$_TEST['HELLO']['FLOOR1'] = array(
'a' => 1,
'b' => 2,
'c' => 4,
'd' => 8
);
$_TEST['HELLO']['FLOOR1'] = array(
'a' => 1,
'b' => 2
);
I'm looking at this code, and there doesn't seem to be any definition for 'hello' and 'floor1' and 'floor2'.
Does PHP just dynamically you to name array indexes like this? And what about the data type?
yes
>> And what about the data type?
types are fluid, the variable will be typed based on what you store in it or how you create it. You can retype on the fly as well, though this does sometimes allow for error if you don't pay close attention.
The indices are case-sensitive and therefore would be 'HELLO', 'FLOOR1' and 'FLOOR2', respectively. I believe you also have a misspelling as you don't actually have a 'FLOOR2' index. Try the following:
$_TEST = array();
#
$_TEST['HELLO']['FLOOR1'] = array(
'a' => 1,
'b' => 2,
'c' => 4,
'd' => 8
);
#
$_TEST['HELLO']['FLOOR2'] = array(
'a' => 1,
'b' => 2
);
echo '<pre>';
[url=http://www.php.net/print-r]print_r[/url]($_TEST); #print the array out
echo '</pre>';
Here's more information on arrays for your reading pleasure :)
[php.net...]