PHP: Slice array
25 September 2022 (Updated 25 September 2022)
$a = [2, 4, 6, 8, 10, 12, 14];
print_r(array_slice($a, 2, 1));
// [6]
print_r(array_slice($a, 2, 2));
// [6, 8]
print_r(array_slice($a, 2, 3));
// [6, 8, 10]
print_r(array_slice($a, 2));
// [6, 8, 10, 12, 14]
Sources
Tagged:
PHP
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment