Hi all,
I have a question about the internal implementation of PHP's hashtables. I
did some researches, but I didn't find the answer.
Here is an example of what I would like to understand.
Start by creating an array:
$a = array();
Fill it, using implicit and explicit keys:
$a[] = 'cc';
$a[1] = 'dd';
If we look at what's inside, we get:
Array
(
[0] => cc
[1] => dd
)
OK, everything is obvious. Now, I add a value at the beginning of the array:
array_unshift($a, 'ee');
Do a print_r() again:
Array
(
[0] => ee
[1] => cc
[2] => dd
)
As you can see, the keys for 'cc' and 'dd' have been recalculated. It works
as espected.
My question is how does it work? Are all numeric keys computed when the
array_shift() is done? Or is the iterator calculating them on-the-fly?
Thanks.
Amaury