php array subset by slicing

Solutions on MaxInterview for php array subset by slicing by the best coders in the world

showing results for - "php array subset by slicing"
Iris
30 Nov 2017
1
2<?php
3$input array("a""b""c""d""e");
4
5$output = array_slice($input2);      // returns "c", "d", and "e"
6$output = array_slice($input, -21);  // returns "d"
7$output = array_slice($input03);   // returns "a", "b", and "c"
8
9// note the differences in the array keys
10print_r(array_slice($input2, -1));
11print_r(array_slice($input2, -1true));
12?>
13/*
14Array
15(
16    [0] => c
17    [1] => d
18)
19Array
20(
21    [2] => c
22    [3] => d
23)
24*/
25