This program is meant to be run from the wordFind page.

HERE; } else { } else { //get puzzle data from HTML form $boardData = array( "width" => filter_input(INPUT_POST, "width"), "height" => filter_input(INPUT_POST, "height"), "name" => filter_input(INPUT_POST, "name") ); //try to get a word list from user input if (parseList() == TRUE){ $legalBoard = FALSE; //keep trying to build a board until you get a legal result while ($legalBoard == FALSE){ clearBoard(); $legalBoard = fillBoard(); } // end while //make the answer key $key = $board; $keyPuzzle = makeBoard($key); //make the final puzzle addFoils(); $puzzle = makeBoard($board); //print out the result page printPuzzle(); } // end parsed list if } // end word list exists if //get puzzle data from HTML form $boardData = array( "width" => filter_input(INPUT_POST, "width"), "height" => filter_input(INPUT_POST, "height"), "name" => filter_input(INPUT_POST, "name") ); //try to get a word list from user input if (parseList() == TRUE){ //keep trying to build a board until you get a legal result while ($legalBoard == FALSE){ clearBoard(); $legalBoard = fillBoard(); } // end while //make the answer key $key = $board; $keyPuzzle = makeBoard($key); //make the final puzzle addFoils(); $puzzle = makeBoard($board); //print out the result page printPuzzle(); } // end parsed list if } // end word list exists if function parseList(){ //gets word list, creates array of words from it //or return false if impossible global $word, $wordList, $boardData; $wordList = filter_input(INPUT_POST, "wordList"); $itWorked = TRUE; //convert word list entirely to upper case $wordList = strtoupper($wordList); //split word list into array $word = split("\n", $wordList); foreach ($word as $currentWord){ //take out trailing newline characters $currentWord = rtrim($currentWord); //stop if any words are too long to fit in puzzle if ((strLen($currentWord) > $boardData["width"]) && (strLen($currentWord) > $boardData["height"])){ print "$currentWord is too long for puzzle"; $itWorked = FALSE; } // end if } // end foreach return $itWorked; } // end parseList