News for hackers. Stuff that matters.
Re:PHP 7's new hashtable implementation by imaginenore on Tuesday December 23, 2014 @01:30AM (#8787041)
There are no arrays in PHP.

There are only hash tables that are called "array" for simplicity.

Re:PHP 7's new hashtable implementation by jakobegger on Tuesday December 23, 2014 @04:28AM (#8787440)
They aren't really hash tables either, because they additionally store the order of the keys (in a normal hash table, order would be arbitrary)
Re:PHP 7's new hashtable implementation by colordrops on Tuesday December 23, 2014 @02:15AM (#8787172)
How do they maintain their order?
Re:PHP 7's new hashtable implementation by _RPM on Tuesday December 23, 2014 @02:31AM (#8787200)
By using a doubly linked list, where the first element in the "bucket", contains the next pointer to the next element in the hash table. Read zend_hash.h & zend_hash.c It is fairly complicated and explaining it in depth is beyond the scope of this comment.

This "bucket" also handles the collisions by using separate chaining. There is actually two "next" pointers, one for the chains, and one for the next element in order of insertion. Very confusing and requires reading through the code and playing with it.

Re:PHP 7's new hashtable implementation by Retra on Tuesday December 23, 2014 @02:24AM (#8787186)
You put things in order by memory address and they stay in order when you access them. An array is just a special case of a hash map -- one with a trivial hash function.

That's why the lend themselves to the same syntax so well.

Re:PHP 7's new hashtable implementation by patkai on Tuesday December 23, 2014 @02:03AM (#8787135)
You made my day, guys, please don't stop :)