[Year 12 SofDev] Records and Arrays

Laurie Savage savage.john.l at edumail.vic.gov.au
Wed Aug 18 13:57:01 EST 2010


I have a problem. In Fitzpatrick and Keane p. 161 (and in the 2007 exam)
arrays and records are primarily differentiated by data type. So the text
says: "An array is an indexed collection of elements of the same type of
data"; "A ... record represents a group of different data elements".

 

But, in PHP, this works:

 

<?php 

$pizzaToppings = array('onion', 'tomato', 'cheese', 'anchovies', 'ham',
'pepperoni', 1.6, 200); 

 

echo "<h1>We like $pizzaToppings[5] PIZZA!</h1>";

 

$num = $pizzaToppings[6] * $pizzaToppings[7];

echo $num;

?>

 

i.e. the array is storing data of different types and not storing the
numeric data as a string. What am I missing here? I've done a search, but
these are the only references I've seen that define this as the main
difference. I've been labouring under the delusion that an array lives in
volatile memory and disappears once the application halts or reinitialises
and a record is written to disk. I know from the web that I'm not alone
here.

 

Laurie Savage

Pascoe Vale Girls College


Important - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Early Childhood Development.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20100818/efcec734/attachment.html 


More information about the sofdev mailing list