Martha's CIS 52 Lab #2 Number Exercise #6

Lab #2 Exercise #6. Remove the last two chunks of values from the following array: 

         $array = array("Zero"=>"PHP", "One"=>"Perl", "Two"=>"Java");

Output the removed chunks, which are [One] => Perl and [Two] => Java,

and the remaining chunk, which is     [Zero] => PHP

**************************************************************

CODES:

<?php 
echo "<b>Original array</b> using <b>print_r()</b> is: <br />";
// Remove the last two chunks of values from the following array: 
$array = array("Zero"=>"PHP", "One"=>"Perl", "Two"=>"Java");
print_r($array);
echo "<br />";
// Output the removed chunks, which are
// [One] => Perl and [Two] => Java, and the remaining chunk, which is 
echo "Using <b>array_slice()</b>:<br />";
$b = array_slice($array, 1, 2);
// [Zero] => PHP
$c = array_slice($array, -4, 1);
print_r($b);
echo "<br />";
print_r($c);
?>

**************************************************************

ANSWER:

Original array using print_r() is:
Array ( [Zero] => PHP [One] => Perl [Two] => Java )
Using array_slice():
Array ( [One] => Perl [Two] => Java )
Array ( [Zero] => PHP )