Both the things you are describing are arrays. The only difference between the two is that you are explicitly setting the keys for the second one, and as such they are known as associative arrays. I do not know where you got the Hash terminology from (Perl?) but that's not what they are referred as in PHP.
So, for example, if you were to do this:
$foo = array(1,2,3,4,5);
print_r($foo);
The output would be:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
As you can see, the keys to access the individual values you put in were created for you, but are there nonetheless. So this array is, essentially, associative as well. The other "type" of array is exactly the same way, except you are explcitily saying "I want to access this value with this key" instead of automatic numeric indexes (although the key you provide could also be numeric).
$bar = array('uno' => 'one', 'dos' => 'two');
print_r($bar);
Would output:
Array
(
[uno] => one
[dos] => two
)
As you might then expect, doing print $bar['one']
would output uno
, and doing $foo[0]
from the first example would output 1
.
As far as functions go, PHP functions will most of the time take either one of these "types" of array and do what you want them to, but there are distinctions to be aware of, as some functions will do funky stuff to your indexes and some won't. It is usually best to read the documentation before using an array function, as it will note what the output will be depending on the keys of the array.
You should read the manual for more information.