Function __global->array_slice

Definitions

sources_custom/phpstub.php

  • Extract a slice of the array.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: array

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$array array No No required parameter N/A N/A The array
$offset integer No No required parameter N/A N/A The offset
$length ?integer No No Null N/A N/A The length (null: up to the end of the array)
$preserve_keys boolean No No False N/A N/A When set to TRUE keys will be preserved. Default is FALSE which will reindex the slice numerically.

Returns

  • The slice
  • Type: array
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Extract a slice of the array.
 *
 * @param  array $array The array
 * @param  integer $offset The offset
 * @param  ?integer $length The length (null: up to the end of the array)
 * @param  boolean $preserve_keys When set to TRUE keys will be preserved. Default is FALSE which will reindex the slice numerically.
 * @return array The slice
 */

function array_slice(array $array, int $offset, ?int $length = null, bool $preserve_keys = false) : array