prezbedard
02-18-2006, 11:17 PM
I am studying php and am on a chapter dealing with arrays.
I am trying to write a script which prints to the screen 2 items in a multi-dimensional array. Now I read there are 2 ways to do a MD array
1. $master_array =array('array1','array2');
$array1=array('item1','item2');
$array2=array('item1','item2');
2.$master_array=array('array1'=>('item1','item2'),'array2'=>array('item1','item2'));
When I use the first method and put the code
print($master_array[0][0]);
its prints array1 item1
but when I use the same print code for the 2nd method it does nothing unless
I change the first item to the actual name of the array. i.e.
print($master_array['array1'][0]);
am I doing something wrong or is that how it works?
I am trying to write a script which prints to the screen 2 items in a multi-dimensional array. Now I read there are 2 ways to do a MD array
1. $master_array =array('array1','array2');
$array1=array('item1','item2');
$array2=array('item1','item2');
2.$master_array=array('array1'=>('item1','item2'),'array2'=>array('item1','item2'));
When I use the first method and put the code
print($master_array[0][0]);
its prints array1 item1
but when I use the same print code for the 2nd method it does nothing unless
I change the first item to the actual name of the array. i.e.
print($master_array['array1'][0]);
am I doing something wrong or is that how it works?