There is an internal implementation for “arrays” in PHP “behind the scenes” written in C. This implementation defines the details of how the array data is actually stored in memory, how arrays behave, how they can be accessed, etc. Part of this C implementation is an “array pointer” that simply points to a specific index of the array. In a very simplified PHP code, this is something like this:
class Array { private $data = []; private $pointer = 0; public function key() { return $this->data[$this->pointer]['key']; } }
You do not have direct access to this array pointer from PHP code, you can just indirectly modify it and influence it using PHP functions such as end , reset , each , etc. These functions need to work; otherwise you could not iterate over the array using next() , because where would he remember what the "next" record is?
source share