Generate a valid array key from an URL string in PHP
- by John Riche
I have a PHP array with some predefined values:
$aArray = array(
0 => 'value0',
1 => 'value1'
);
I need to create a function where the string input will always return the same, valid, array key so that when I call:
GiveMeAKey('http://www.google.com'); // May return 0 or 1
I receive always the same key (I don't care which one) from the array. Obvisously I can't store the relationship in a database and the string passed to the GiveMeAKey method can be any URL.
I wonder if there is a way of doing that ?