I have a dictionary loaded into an assoc array. Elements are sorted, and there are a million Items. The dictionary is in the form term = > definition. Would it be quicker to search for a definition by using array($term) to access the key, or doing a binary search on the array? Would it be quicker over single pass or multiple term searches?
            Asked
            
        
        
            Active
            
        
            Viewed 252 times
        
    0
            
            
        - 
                    Internally PHP uses a [hash table](https://nikic.github.io/2012/03/28/Understanding-PHPs-internal-array-implementation.html) to access an element in an array by key. Generally a hash lookup is faster that binary search, [but not always](https://stackoverflow.com/questions/360040/which-is-faster-hash-lookup-or-binary-search) – Brett Gregson Jan 24 '19 at 13:04
- 
                    is hash table is linear way – Ahsan Sajjad Jan 24 '19 at 13:27
1 Answers
1
            If you have a million items, do not use an associative array, but use a database. The fastest way to access an array is isset()
 
    
    
        Antonello Amici
        
- 26
- 1
- 4
