explon
V2EX  ›  PHP

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

  •  
  •   explon · Apr 15, 2013 · 4226 views
    This topic created in 4819 days ago, the information mentioned may be changed or developed.
    $test = array( 1 => 'a', 9 => 'b' );

    print_r(array_merge($test));
    4 replies    1970-01-01 08:00:00 +08:00
    dorentus
        1
    dorentus  
       Apr 15, 2013
    直接用 array_values($test) 不是更好。。。
    explon
        2
    explon  
    OP
       Apr 15, 2013
    @dorentus 只是讨论发现一个隐藏功能
    breeswish
        3
    breeswish  
       Apr 15, 2013 via Android
    感谢分享=w=
    blandlove
        4
    blandlove  
       Apr 15, 2013
    当 key , type 为 number 时 会对所有此类型的key 自动编号
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   936 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:59 · PVG 05:59 · LAX 14:59 · JFK 17:59
    ♥ Do have faith in what you're doing.