30秒学会 PHP 片段 · 2018年6月3日

30秒学会 PHP 片段 – last

Returns the last element in an array.

Use end() to return the last item in the array.

代码实现

function last($items)
{
  return end($items);
}

使用样例

last([1, 2, 3]); // 3