A key is the value that goes inside the [] in the variable name.
If using a standard array (and in most programming languages) these are integers starting with 0.
However, in PHP the key can be any value.
for example, an array containing the prices of fruit might contain:
$price['apple'] = 0.75
$price['orange'] = 0.99
$price['lemon'] = 0.57
where 'apple', 'orange' and 'lemon' are the keys and .75. .99 and .57 are the values.
In your case the filename would go in the brackets:
$file_array[$filename] = filemtime ($filename);
Thus, you would access the integer timestamp of the last modified date of the file "/path/to/my/file' like this:
$file_array['/path/to/my/file'];
it would be similar to accessing an array in any other language:
$file_array[0] = time();
$file_array[1] = time() - 50;
However, instead of using an integer as the key, you are simply using the filename.
Then, as devinemke suggested, you can access the keys of the array with the following code:
foreach ($file_array as $key => $value)
{
echo '<tr><td>' . $key . '</td><td>' . date ('Y-m-d h:i:s', $value) . '</td></tr>';
}
This stores the key in the variable $key and the last modified date in the variable $value. It then echos this information in a nice format.
This is what they call an associative array (or, in some languages, a hash), as each key is associated with one value (i.e. in this case each filename is associated with one last modified date).
I gather that it could be looked at as a two dimensional array in a sense that you do have two sets of data which are associated with each other. However, by using an associative array, it ensures that the filename and last modified date stay together as a pair during the sorting process.
If using a 2-D array it is possible for the pairs to get jumbled, and then you would end up with files with incorrect last modified dates, which is not what you want.
Chris