Looking Back at Old Code

No Gravatar
Print Friendly

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 Post a comment

  1. beppu

    April 12, 2011 at 5:34 am

    I bet you were trying to copy an array but accidentally typed $items[$i] twice.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>