I just came across the following gem in some PHP code I wrote for a web application about seven years ago:
for ($i = 0; $i < count($items); $i++) $items[$i] = $items[$i];
I cannot begin to understand the logic behind this. I’ve tried to plumb the depths of my knowledge of PHP and how variables can cause E_NOTICE messages when they are referenced while uninitialized, but I simply can’t figure out what I was trying to accomplish with that line of code.
It makes me happy to look back on what I have done and realize how much I’ve learned since then.
1 comment
I bet you were trying to copy an array but accidentally typed $items[$i] twice.