note 57762 deleted from function.in-array by hholzgra

From: Date: Sun, 06 Aug 2006 12:01:31 +0000
Subject: note 57762 deleted from function.in-array by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115589@lists.php.net to get a copy of this message
Note Submitter: evildictaitor at hotmail dot com ---- To look through a large array, it is much more efficient when it is sorted to use a binary chop method, so that the number of calls is equal to log(number_of_values_in_array) / log2 rather than equal to the number of values in the array. For a million values in an array, it can therefore return whether this index exists in a file using no more than 20 calls to the array rather than a million. This makes it 50,000 times more efficient for an array of this size. I'm sure you can imagine what a million calls can do to a processor, and it isn't nice. Hope this helps someone.

« previous php.notes (#115589) next »