3 ms·
PHP does at least have an optimised internal representation for arrays with sequential integer keys, where it can avoid having a hash table and just do linear i
by TazeTSchnitzel 4y ago
PHP does at least have an optimised internal representation for arrays with sequential integer keys, where it can avoid having a hash table and just do linear indexing: https://www.npopov.com/2014/12/22/PHPs-new-hashtable-implementation.html#packed-hashtables https://www.npopov.com/2014/12/22/PHPs-new-hashtable-impleme...
But a tradeoff in that design is it still has to keep track of keys and update them if you remove stuff from the start of the array. Adding and removing elements at the end is very fast, though.