two dimensional array data structure in PHP programming language

The array data structure in PHP programming languages

Disclaimer: The PHP array data structure implemented in this section, is not for production usage, it is only for teaching purposes. Then use it on your own responsibility, if you like.

In PHP, the array data structure itself is implemented based on another data structure. This bottom underlying data structure is the hash table. Then almost all desired array data structure properties and operations, must be translated into hash table properties and operations. For example, if you need a GetItemAt method to access the item $i in an array, it uses an equivalent method, that already exists for the hash table.
As you may guess, this may not result in optimum performance, in the case of array data structure. On the other hand, some behaviors we like to be there, in an array data structure implementation, may not be there! For example in many programming languages (like C, C++, Java, etc.) you encounter an exception when accessing an out of the bound index in an array.

In fact, the latter situation has a good explanation. Arrays in PHP are dynamic and very handful to make easy use of them. Then you can access, or even assign an undefined index of an array without getting an exception.

BTW, we know that there is not a simple data structure implementation inside the PHP itself (and honestly there is no real-world need to implement such a thing). Here we try to make the same taste for simple arrays (as in other popular languages) in PHP. On the other hand, if someone tends to implement such a feature for the PHP community, it is better to go through PHP extension development and make such tools. (and in that case, that would be a data structure wrapper implementation in C programming language)
OK, enough talk! let's dive into the implementation.

A two array data structure implementation in PHP, version 1

A two array data structure implementation in PHP, version 2

A two array data structure implementation in PHP, version 3