Exemple 1
Structure du tableau initial :
Array ( [UN] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) [DEUX] => Array ( [0] => a [1] => b [2] => c ) [0] => Array ( [0] => A [1] => B [2] => C [3] => D [4] => E ) [1] => Array ( [0] => 11 [1] => 12 [2] => 13 [3] => 14 [4] => 15 ) )
array_slice($tab,1,2) donne : Array ( [DEUX] => Array ( [0] => a [1] => b [2] => c ) [0] => Array ( [0] => A [1] => B [2] => C [3] => D [4] => E ) )
Exemple 2
Structure du tableau initial :
Array ( [0] => Spock [1] => Batman [2] => Dark Vador [3] => Hal [4] => Frodo [5] => Sky Walker [6] => Amidala [7] => Alien )
array_slice($heros,0,5)Array ( [0] => Spock [1] => Batman [2] => Dark Vador [3] => Hal [4] => Frodo )
array_slice($heros,-5,5) Array ( [0] => Hal [1] => Frodo [2] => Sky Walker [3] => Amidala [4] => Alien )
array_slice($heros,-5,3) Array ( [0] => Hal [1] => Frodo [2] => Sky Walker )
array_slice($heros,1,-2) Array ( [0] => Batman [1] => Dark Vador [2] => Hal [3] => Frodo [4] => Sky Walker )
array_slice($heros,-5,-2) Array ( [0] => Hal [1] => Frodo [2] => Sky Walker )