30 seconds of PHP

  Back to Home

tail

arraybeginner

Returns all elements in an array except for the first one.

Use array_slice() and count() to return all the items in the array except for the first one.

function tail($items)
{
  return count($items) > 1 ? array_slice($items, 1) : $items;
}