PHP: Remove the first and last item of the array

前端 未结 7 475
旧巷少年郎
旧巷少年郎 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:27

    Using array_slice is simplest

    $newarray = array_slice($array, 1, -1);
    

    If the input array has less than 3 elements in it, the output array will be empty.

    0 讨论(0)
提交回复
热议问题