explon
V2EX  ›  PHP

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

  •  
  •   explon · Apr 15, 2013 · 4346 views
    This topic created in 4894 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   ·   Privacy   ·   Solana   ·   3326 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 11:45 · PVG 19:45 · LAX 04:45 · JFK 07:45
    ♥ Do have faith in what you're doing.