As far as I know all arrays in php are hash arrays. Your "serial" array is
actually a hash array with numeric keys, so in your example using numeric
keys and having to loop through them has nothing going for it.

I'm sure someone will tell me if I'm wrong.

Tim <> 

        From:  Eric McKeown [SMTP:[EMAIL PROTECTED]]
        Sent:  09 January 2002 05:53
        To:  [EMAIL PROTECTED]
        Subject:  serial array vs. hash....

        Hi folks,

        Quick question about the performance implications of looking up info
        a hash (associative array) vs. looking it up in a serial array.  I
        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.
        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
        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
        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
        check here to see if anyone could confirm or refute my hunch....

        Thanks for your help,


PHP General Mailing List (
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