Example 1 — Take Part of a List
Take three items starting from position 1.
<?php
$letters = ["a", "b", "c", "d", "e"];
$part = array_slice($letters, 1, 3);
echo implode(", ", $part), PHP_EOL; How It Works
- Create a list of five letters. Positions start at 0.
- Offset 1 starts at "b" and length 3 takes three items.
- The slice is a new array with "b", "c" and "d".
- implode() prints the items separated by commas.

