I am looking to have some values for a string, and wanted to get some sort of key for an array to hold its’ values eg: “This is a test”
$tmpAr['ce114e4501d2f4e2dcea3e17b546f339'] = array("somevar" => "somedata", "morevar" => "moredata");
The reason I would like to do it this way, is because I don’t know exactly what text will be used as the key, and rather then strip every possible problematic piece, the hash would take care of it.
There will likely be less then 100 strings in each grouping, so the likely hood of duplicate keys is very small.
Is there any issue with using this?
This is not a good method because you can have key collisions. As you can read from wikipedia
In general, using the hashing function to create key is never a good choise because of the Pigeonhole principle. The key collisions will cause an override of the values in that array position and this behavior will be very hard to debug. Thus, you’ll run in serious problems and headache.
In conclusion, I suggest you to think another way to create your keys that will ensure you the uniqueness of the latters.