From: jessewalker at gmail dot com Operating system: Linux PHP version: Irrelevant Package: Arrays related Bug Type: Bug Bug description:Quirks with array entries 08 / 8 and 09 / 9 compared to other entries.
Description: ------------ I'd set up a multi-dimensional array with the first level having 12 entries 01 to 12 (months), and the second level having 01 to 31 (days) depending on the month. e.g., $months[01][01] = "..."; ... $months[01][31] = "..."; $months[02][01] = "..."; ... $months[02][28] = "..."; ... I found that when iterating through $months with: foreach($months[1] as $day => $entry) and just printing out the $day value, that I'd get results like: 1 .. 7 0 10 .. 31 Notice that 8 and 9 don't print out, but 0 (zero) instead. All other numbers are fine. I tested this all the way up to $months[12] and get the same result, though it fails miserably on $months[8] and $months[9] with the following: PHP Notice: Undefined offset: 8 in /home/pi/php/test.php on line 10 PHP Warning: Invalid argument supplied for foreach() in /home/pi/php/test.php on line 10 Remember that I set my $months array up with 08 and 09 (same as the other numbers having a leading zero). So it's not just an issue at the 2nd level of a multi-dimensional array. With this in mind I reduced my test code down and still get the same issue. It's not only a multi-dimensional array issue, but an array issue affecting entries 8 and 9. The multi-dimensional array gives a slightly different result, so this is why I've mentioned it first. I get the exact same results with: PHP 5.3.6-13ubuntu3.9 with Suhosin-Patch (cli) (built: Sep 12 2012 19:02:11) -- from XBMCbuntu on an HP ProLiant MicroServer N40L PHP 5.6.0-dev (cli) (built: Jan 27 2013 20:37:53) -- from Git master, on the same box I run XBMCbuntu on PHP 5.4.4-11 (cli) (built: Jan 18 2013 02:49:29) -- from Raspbian "Wheezy" 2012-12-16 on a Raspberry Pi All systems fully up to date using apt-get. I ran my tests from the CLI with `php test.php`, and the Git test with `/opt/bin/php test.php`. I know that I could just not set my arrays up with 01..09, and use 1..9 instead - though it's still a quirky issue all the same. Is there any explanation for this, or am I missing something? I'm more than happy to provide full code if requested. The test code provided should be enough to get some idea. Test script: --------------- <?php $num[1] = "One"; $num[01] = "ZeroOne"; $num[02] = "ZeroTwo"; $num[2] = "Two"; $num[8] = "Eight"; $num[08] = "ZeroEight"; $num[09] = "ZeroNine"; $num[9] = "Nine"; print("1: ".$num[1]."\r\n"); print("01: ".$num[01]."\r\n"); print("02: ".$num[02]."\r\n"); print("2: ".$num[2]."\r\n"); print("8: ".$num[8]."\r\n"); print("08: ".$num[08]."\r\n"); print("09: ".$num[09]."\r\n"); print("9: ".$num[9]."\r\n"); ?> Expected result: ---------------- 1: ZeroOne 01: ZeroOne 02: Two 2: Two 8: ZeroEight 08: ZeroEight 09: Nine 9: Nine Actual result: -------------- 1: ZeroOne 01: ZeroOne 02: Two 2: Two 8: Eight 08: ZeroNine 09: ZeroNine 9: Nine -- Edit bug report at https://bugs.php.net/bug.php?id=64086&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64086&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64086&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64086&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64086&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64086&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64086&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64086&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64086&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64086&r=support Expected behavior: https://bugs.php.net/fix.php?id=64086&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64086&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64086&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64086&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64086&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64086&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64086&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64086&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64086&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64086&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64086&r=mysqlcfg