<?php

// getnotes.php by John Phillips on 6/5/2002 last revised 6/5/2002
// This file is brought into the main php program with an include statement.

// DESCRIPTION:
// Each notes page is a plain html file. However, I want to read in
// this file and insert it within a table in my main page. 
// Therefore, I need to retrieve just the stuff between the body tags.
// Although, this step does not really seem necessary, we will do it to help
// generate valid HTML code.

$fileName "content/{$menu}/{$item}.html";

// Read in the HTML notes file (as an array) and then implode the array
// into a single string variable.
// Note: the @ signs suppress possible error messages.
 
$notes = @implode('', @file($fileName));

// Use the PHP Perl-like regular expression to split the string on <body...>
// Everything that occurs after the body tag is placed in $matches[1].

$matches preg_split("/<body[^>]*>/i"$notes);

// Now split on </body>.
// Everything that occurs before </body> is placed in $matches[0]. 

$matches preg_split('/<\/body>/i'$matches[1]);

// Display the result

if( $matches[0] != null )
{
  echo 
$matches[0];

else 
{
  echo 
"Sorry, the file '$fileName' was not found.\n";
}

?>