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

前端 未结 11 601
说谎
说谎 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:32

    with array_shif you have two operations:

    1. retrive the firs element
    2. shift the array

    if you access by index, actually you have only one operation.

提交回复
热议问题