Arrays: array_shift($arr) or $arr[0]?

前端 未结 11 668
说谎
说谎 2021-01-14 04:08

Which one would you use?

Basically I only want to get the 1st element from a array, that\'s it.

11条回答
  •  自闭症患者
    2021-01-14 04:30

    array_shift will actually remove the specified value from the array. Do not use it unless you really want to reduce the array!

    See here: http://php.net/manual/en/function.array-shift.php

提交回复
热议问题