thankyourtender
V2EX  ›  PHP

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

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

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

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

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