Arrays have an internal pointer, much akin to how a file pointer works. Just reset the array and read the current one. In fact, the reset command when done on an array returns the first record.
reset has nothing to do with keys – the internal pointer is used for iterating the array, not for populating it. Its no different than performing a foreach on it.
reset($myarray);
while ( list($key,$data)=each($myarray) ) {
/* do something here */
}
is functionally identical to:
foreach ($myarray as $key => $data) {
/* do something here */
}
Though nowhere near as elegant. NONE of those commands change the contents of the array or it’s length or keys or anything else. The only thing that’s changed is the internal read pointer… READ pointer.
So for example if you want the first record of the array and it’s key…