$pieces[0]: $pieces[1]

"; $ann = fgets($handle); } if ( $i == 0 ) { noAnnouncements(); } } else { noAnnouncements(); } } function getAnnouncements() { $handle = openFile( "announcements", "r" ); if ( $handle != -1 ) { $ann = fgets($handle); for ($i=0; !feof($handle); $i++) { //echo $ann; $pieces = explode("|", $ann); echo "

$pieces[0]: $pieces[1]

"; $ann = fgets($handle); } if ( $i == 0 ) { noAnnouncements(); } } else { noAnnouncements(); } } function openFile( $fileName, $options ) { if ( file_exists( $fileName ) ) $handle = fopen( $fileName, $options ); else $handle = -1; return $handle; } function getNotes() { $handle = openFile( "notes", "r" ); if ( $handle != -1 ) { $notes = fgets($handle); for( $i=0; !feof($handle); $i++) { //first piece is chapter number, second piece is description, last piece is file name //if any of the first two pieces are missing then only the supplied piece is used //the last piece must always be there. And there must always be two | $pieces = explode("|", $notes); if ( $pieces[0] != "" && $pieces[1] != "" ) echo "$pieces[0]: $pieces[1]
"; elseif ( $pieces[0] != "" ) echo "$pieces[0]
"; elseif ( $pieces[1] != "" ) echo "$pieces[1]
"; $notes = fgets($handle); } if ( $i == 0 ) { echo "We don't have any notes yet, check back soon.
"; } } else { echo "We don't have any notes yet, check back soon.
"; } } function noAnnouncements() { echo date("n/j/Y"); echo ": No announcements"; } ?> CS2604 - Data Structures and File Management
CS2604 - Data Structures and File Management