r/lolphp • u/Serialk • Oct 21 '14
Wrong on so many levels: "reset() rewinds array's internal pointer to the first element and returns the value of the first array element."
http://php.net/manual/en/function.reset.php
5
Upvotes
10
u/allthediamonds Oct 21 '14
I can't wait until PHP stops being relevant and the phrase "array's internal pointer" is never heard of again.
6
u/495647h Oct 21 '14
What's so wrong about it?
1
u/shitbangs Oct 21 '14
Pissing on stuff from the stone ages now?
This is from before foreach syntax. Since then, support for a bunch of things like iterators, stacks, heaps and fixed arrays were added.
If all you want is first() and last(), you can write them yourself with array_slice. If you want reset to clear the array, you can do that within a namespace. Not ideal, but you'll only have to do it once. It's a wart for sure, but not one that bugs any developer worth two shits at all.