Hi folks,

Quick question about the performance implications of looking up info in
a hash (associative array) vs. looking it up in a serial array.  I have
a script that will be running a function (actually several similar
functions) up to 1500 times to verify that certain data values are in a
valid list.  My list might have anywhere from 2 to 100 valid values.  I
could store the list in a conventional serial array...

$valid[0] = "Valid One";
$valid[1] = "Valid Two";
$valid[2] = "Valid Three";
and so on, and then use a for loop to iterate through the contents of
the array each time that I need to check to see if I have a valid
value.  On the other hand, I could create a hash that looks like...

$valid["Valid One"] = "some value";
$valid["Valid Two"] = "some other value";

and so on, and then simply check to see if the entry exists in the
associative array in order to determine whether it is valid.  I suspect
that the latter method would be much more efficient, and I intend to
test the two techniques myself to find out, but I just thought I would
check here to see if anyone could confirm or refute my hunch....

Thanks for your help,


PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to