<html>
<! Slice.php                                                  >
<! Chapter 6, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script declares an array and demonstrates the         >
<! array_slice() function.                                    >
<head>
<title>
  Chapter 6 : Slice.php
</title>
</head>
<body>
<?php
  // Declare array variables.
  $scandinavia = array("Denmark","Finland","Iceland","Ireland"
                      ,"Norway","Sweden","United Kingdom");

  // Read and print array keys and values to the page.
  foreach($scandinavia as $code => $name)
    print "[".$code."][".print_r($name,true)."].<br>";

  // Print a line.
  print "<hr>";

  // Sort the array members.
  $sliced = array_values(
              array_unique(
                array_merge(
                  array_slice(
                    $scandinavia,array_search("Finland",$scandinavia),1)
               ,array_slice(
                  $scandinavia,array_search("Norway",$scandinavia),2))));

  // Read and print spliced array keys and values to the page.
  foreach($sliced as $code => $name)
    print "[".$code."][".print_r($name,true)."].<br>";
?>
</body>
</html>
