PHP: Remove the first and last item of the array

前端 未结 7 597
旧巷少年郎
旧巷少年郎 2021-01-31 07:47

Suppose I have this array:

 $array = array(\'10\', \'20\', \'30.30\', \'40\', \'50\');

Questions:

What is the fastest/

7条回答
  •  一个人的身影
    2021-01-31 08:16

    array_slice is going to be the fastest since it's a single function call.

    You use it like this: array_slice($input, 1, -1);

    Make sure that the array has at least 2 items in it before doing this, though.

提交回复
热议问题