PHP json_encode as object after PHP array unset()
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm experiencing odd behavior with json_encode after removing a numeric array key with unset . The following code should make the problem clear. I've run it from both the CLI and as an Apache mod: PHP version info: C : \Users\usr\Desktop > php - v PHP 5.3 . 1 ( cli ) ( built : Nov 20 2009 17 : 26 : 32 ) Copyright ( c ) 1997 - 2009 The PHP Group Zend Engine v2 . 3.0 , Copyright ( c ) 1998 - 2009 Zend Technologies PHP Code <? php $a = array ( new stdclass , new stdclass , new stdclass ); $a [ 0 ]-> abc = '123' ; $a [ 1 ]-> jkl = '234