<html>
<! InArray.php                                                >
<! Chapter 6, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script declares an array then uses the in_array()     >
<! function search for a matching value attempting to use     >
<! it to process data.                                        >
<head>
<title>
  Chapter 6 : InArray.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 search string.
  $search = "Dr.";

  // Check for valid value before getting key value.
  if (in_array($search,$salutation,true))
    print "[".$salutation[array_search($search,$salutation,true)]."]";
  else
    print "[Not found.]";

?>
</body>
</html>
