V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
explon
V2EX  ›  PHP

array_merge 只给定一个数组可以对其进行重新编号

  •  
  •   explon · 2013-04-15 13:47:02 +08:00 · 3397 次点击
    这是一个创建于 4028 天前的主题,其中的信息可能已经有所发展或是发生改变。
    $test = array( 1 => 'a', 9 => 'b' );

    print_r(array_merge($test));
    4 条回复    1970-01-01 08:00:00 +08:00
    dorentus
        1
    dorentus  
       2013-04-15 15:34:52 +08:00
    直接用 array_values($test) 不是更好。。。
    explon
        2
    explon  
    OP
       2013-04-15 16:13:45 +08:00
    @dorentus 只是讨论发现一个隐藏功能
    breeswish
        3
    breeswish  
       2013-04-15 17:29:37 +08:00 via Android
    感谢分享=w=
    blandlove
        4
    blandlove  
       2013-04-15 18:08:31 +08:00
    当 key , type 为 number 时 会对所有此类型的key 自动编号
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2690 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 15:58 · PVG 23:58 · LAX 08:58 · JFK 11:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.