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.

Advertisement
This entry was posted in PHP, Programming. Bookmark the permalink.

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

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s