<html>
<! Splice.php                                                 >
<! Chapter 6, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script declares an array and demonstrates the         >
<! array_splice() function.                                   >
<head>
<title>
  Chapter 6 : Splice.php
</title>
</head>
<body>
<?php
  // Declare an array variables.
  $scandinavia = array("dk"=>"Denmark","is"=>"Iceland"
                      ,"no"=>"Norway","se"=>"Sweden");

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

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

  // Splice out of one array to another.
  $spliced = array_splice(
               $scandinavia,array_search("Denmark",$scandinavia),1
               ,array("fi"=>"Finland"));

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

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

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