Associative array doesn't use sequential numbers as its index like regular arrays which means you can't use a standard for next loop. For example, a regular array with sequential numbers for its indices takes the form:
$arrayname[0]='something';
$arrayname[1]=somethingelse';
An associative array (or 'hash table', thanx Echo) might take the form:
$arrayname['author'] = "John Cook";
$arrayname['country'] = "Australia";
A more universal method of looping through both types of arrays than the usual for($i=0; $i<count(array); $i++) is the following code:
<?php
foreach($arrayname as $key=>$value)
{
echo $key.": ".$value;
}
?>
|