ID: 31072 Updated by: [EMAIL PROTECTED] Reported By: komura at ma9 dot seikyou dot ne dot jp -Status: Assigned +Status: Closed Bug Type: Variables related Operating System: Linux PHP Version: 4.3.10RC2 Assigned To: helly New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2004-12-13 16:34:31] [EMAIL PROTECTED] Marcus, you broke this... so fix it :) ------------------------------------------------------------------------ [2004-12-13 15:55:30] komura at ma9 dot seikyou dot ne dot jp Description: ------------ var_export() in PHP 4.3.10RC1/RC2 does not output an array element with an empty string key. It appears that the following patch is the cause of this problem. http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.150.2.14&r2=1.150.2.15&ty=u @@ -260,13 +267,17 @@ static int php_array_element_export(zval if (hash_key->nKeyLength==0) { /* numeric key */ php_printf("%*c%ld => ", level + 1, ' ', hash_key->h); } else { /* string key */ - char *key; - int key_len; - key = php_addcslashes(hash_key->arKey, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC); - php_printf("%*c'", level + 1, ' '); - PHPWRITE(key, key_len); - php_printf("' => "); - efree(key); + if (va_arg(args, int) && hash_key->arKey[0] == '\0') { + return 0; + } else { + char *key; + int key_len; + key = php_addcslashes(hash_key->arKey, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC); + php_printf("%*c'", level + 1, ' '); + PHPWRITE(key, key_len); + php_printf("' => "); + efree(key); + } } Reproduce code: --------------- var_export( array( '' => 1, 'a' => 2 ) ); Expected result: ---------------- array ( '' => 1, 'a' => 2, ) Actual result: -------------- array ( 'a' => 2, ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31072&edit=1