Extract a slice of the current array.

/**
 * Extract a slice of the current array.
 *
 * @param int      $offset       Slice begin index.
 * @param int|null $length       Length of the slice. Default is null.
 * @param bool     $preserveKeys Whether array keys are preserved or no. Default is false.
 */
public function slice(int $offset, ?int $length = null, bool $preserveKeys = false): self

Examples

$arrays = Arrays::create(['a', 'b', 'c', 'd', 'e'])->slice(0, 3)->toArray();

print_r($arrays);

Getting Started

Methods