PHP 4.0 Bug #3510: Null indexes for arrays no longer work in PHP4

From: Date: Thu, 17 Feb 2000 01:12:00 +0000
Subject: PHP 4.0 Bug #3510: Null indexes for arrays no longer work in PHP4
Groups: php.dev 
Request: Send a blank email to php-dev+get-15618@lists.php.net to get a copy of this message
From: johannes@erdfelt.com Operating system: Linux PHP version: 4.0 Beta 3 PHP Bug Type: Scripting Engine problem Bug description: Null indexes for arrays no longer work in PHP4 I'm starting to use PHP4 on a website I run and a script which ran fine under PHP3 is causing some problems with PHP4. I've developed a workaround, but I don't know if this is a known change in the language between PHP3 and PHP4. Essentially, I use an index to an array which doesn't exist as an index to an associative array. Here's a test program which reproduces the problem: ereg("(1)(2)", "12", $bar); $foo = array( "" => "1", "bar" => "2", "baz" => "3" ); echo "[" . $foo[$bar[3]] . "]\n"; It'll generate a warning like this: Warning: Illegal offset type in /home/jerdfelt/public_html/foo.php on line 11 I can workaround the problem by doing this: echo "[" . $foo[$bar[3] . ""] . "]\n"; (ie appending a null string to the value from the array bar)

« previous php.dev (#15618) next »