At the moment I initialize as follows:
$my_hash = array();
Populate like this:
$my_hash[$key] = $value;
However when I check for my key as follows
if ($my_hash[$key])
The server throws up an error. How to I check for my key?
At the moment I initialize as follows:
$my_hash = array();
Populate like this:
$my_hash[$key] = $value;
However when I check for my key as follows
if ($my_hash[$key])
The server throws up an error. How to I check for my key?
if(array_key_exists($key, $my_hash)){
// do your stuff
}
It's not exactly a hash table. It's an array data type in PHP.
More operations on arrays can be seen here: http://php.net/manual/en/ref.array.php