Slice With both string and integer keys in PHP

Description

The following code shows how to slice With both string and integer keys.

Example


//from ww w .  j a v a  2  s  . c om
<?php
    $a=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow","e"=>"brown");
    print_r(array_slice($a,1,2));

    $a=array("0"=>"red","1"=>"green","2"=>"blue","3"=>"yellow","4"=>"brown");
    print_r(array_slice($a,1,2));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone