hash tables
hash tables are a great way to sore associated lists of information and also maintain a very low retrieval time (O(1)). a hash table is basically an associative array where the keys can be anything (typically strings) that points to a value. lets say you have a list of people and their addresses. you might want to associate the people with there addresses so that when you look up “jesse mazur” you get “555-1212″. rather than having to traverse the entire array to find the value you simply query the hash table for the key “jesse mazur” and get the value “555-1212″ returned. an easy way to create this type of relationship in php is to simply use an array:
$hashTable = array('my' => 'some data',
'hash' => 'some more data',
'table' => 'even more data');
retrieval from the hash table would be as simple as saying:
echo $hasTable['hash'];
which would display 'some more data' to the screen.
in javascript you would use a json object to do something every similar:
var hashTable = new Array(); hashTable['my'] = 'some data'; hashTable['hash'] = 'some more data'; hashTable['table'] = 'even more data';
and retrieval is as easy as:
document.write(hashTable.table);
which would display 'even more data' to the screen.




