V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
thankyourtender
V2EX  ›  PHP

获取第一个值 最好不要用 array[0] 而是 current (array)

  •  
  •   thankyourtender · Jul 30, 2014 · 4172 views
    This topic created in 4297 days ago, the information mentioned may be changed or developed.
    12 replies    2014-09-06 01:09:16 +08:00
    Keyes
        1
    Keyes  
       Jul 30, 2014 via iPhone
    为什么呢?
    teavoid
        2
    teavoid  
       Jul 30, 2014
    好没头没脑的感觉
    raincious
        3
    raincious  
       Jul 30, 2014
    @Keyes 因为array[0]不一定有。

    但为什么是current?执行了next之后怎么办?
    lyragosa
        4
    lyragosa  
       Jul 30, 2014
    不明所以。
    imn1
        5
    imn1  
       Jul 30, 2014
    如果要多次获取呢?
    wy315700
        6
    wy315700  
       Jul 30, 2014
    @imn1 多次获取用foreach啊
    imn1
        7
    imn1  
       Jul 30, 2014
    @wy315700 我说的是多次获取第一个值,不是顺序获取
    raincious
        8
    raincious  
       Jul 30, 2014
    @imn1

    array_splice。其实这个可以解决包括楼主的问题。所以不明白,非得current?微优化?

    http://stackoverflow.com/questions/2473989/list-of-big-o-for-php-functions
    thankyourtender
        9
    thankyourtender  
    OP
       Jul 30, 2014
    呵呵
    wtbhk
        10
    wtbhk  
       Jul 30, 2014
    已Block
    lzsadam
        11
    lzsadam  
       Jul 30, 2014
    围观
    shanqiu
        12
    shanqiu  
       Sep 6, 2014
    拿的时候 if isset() 判断一下再用吧。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2745 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 98ms · UTC 14:48 · PVG 22:48 · LAX 07:48 · JFK 10:48
    ♥ Do have faith in what you're doing.