30 seconds of PHP

  Back to Home

take

arraybeginner

Returns an array with $n elements removed from the beginning.

Use array_slice() to remove $n items from the beginning of the array.

function take($items, $n = 1)
{
  return array_slice($items, 0, $n);
}