Your hint has some truth. I should probably refactor my tiles array so i can get a reference to $tiles
and go on from there. However you should probably read up about references a bit, as your code would never work as it is there. :)
As for type, that is indeed a constant. Hashes are too slow, thus i used constants to build pseudo-hashes.