Return to Main Page

PHP Tip of the Day: Array Indexing

Ok, I’m not really going to do a PHP tip every day, but here’s something I learned the hard way. I normally don’t index an array like this, but for some reason one day I decided to try it and it came back to haunt me.

$myarray[03] != $myarray[3]
In fact,
$myarray[03] == $myarray[0]
Go figure.

One Response to “PHP Tip of the Day: Array Indexing”

  1. Alex Poole Says:

    Wouldn’t that be an octal number?

    > http://uk2.php.net/manual/en/language.types.integer.php

    Loosely typed is lovely until it bites you on the behind. Perhaps I’m just getting old but sometimes its nice to have type shoved down your throat to avoid hour-killing gotchas like this..

Leave a Reply