<html>
<! Traverse2.php                                              >
<! Chapter 6, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script declares an array and then it resets the       >
<! pointer to the initial element and uses a for loop and     >
<! the prev() function to read backward through items in the  >
<! array.                                                     >
<title>
  Chapter 6 : Traverse2.php
</title>
</head>
<body>
<?php
  // Declare an array variable.
  $salutation = array("Dr.","Mr.","Mrs.","Ms.");

  // Print the formatted contents.
  print "[".(print_r($salutation,true))."]<p>";

  // Set the array pointer to the last element.
  end($salutation);

  // Run once for the total of elements in the array.
  for ($i = 0;$i < count($salutation);$i++)
  {
    print "[".key($salutation)."][".current($salutation)."]<br>";
    prev($salutation);
  }

?>
</body>
</html>
