10) { // Only generate 10 unique random numbers while($random_count < 10) { // Generate a random number between 0 and $random = rand(0, count($appearance_indices[$i]) - 1); // If the number is not already in the array, enter the random value into the array if(!in_array($random, $random_indices[$i])) { $random_indices[$i][$random_count] = $random; $random_count++; } } /* echo "----------------------".$i."------------------------"; // Test code to display randomly generated indices for($j = 0; $j < 10; $j++) { echo "

".strval($random_indices[$i][$j])."

"; } */ } } //Testing //for($i = 0; $i < count($lines); $i++) // echo $lines[$i]."
"; // Display the two links at the top of the page, followed by the "wordbank" area - containing the top 5 words echo "

".$lines[0]."

"; echo "

".$lines[1]."

"; echo "

".$lines[2]."

"; echo "

".$lines[3]."

"; echo "

".$lines[4]."

"; echo "
"; // Creation and population of the "sentence" area - the right side of the page where sentences are displayed // One div with class "sentences" for each of the 5 top words. These divs will be populated with sentences // in which the corresponding word appears echo "
"; // Word 1's sentences echo "
"; // If the word appears in more than 10 sentences, use the previously generated random sample of 10 if( count($appearance_indices[0]) > 10 ) { // Using the 10 random indices from $random_indices for($i = 0; $i < 10; $i++) { // Find the randomly chosen index of the appearances_indices table $appearance_lookup_index = $random_indices[0][$i]; // Find the lines table index stored in the appearances_indices table $index = $appearance_indices[0][$appearance_lookup_index]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } // If the word appears in less than 10 sentences, display all appearances else { for($i = 0; $i < count($appearance_indices[0]); $i++) { $index = $appearance_indices[0][$i]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } echo "
"; // Word 2's sentences echo "
"; if( count($appearance_indices[1]) > 10 ) { // Using the 10 random indices from $random_indices for($i = 0; $i < 10; $i++) { // Find the randomly chosen index of the appearances_indices table $appearance_lookup_index = $random_indices[1][$i]; // Find the lines table index stored in the appearances_indices table $index = $appearance_indices[1][$appearance_lookup_index]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } else { for($i = 0; $i < count($appearance_indices[1]); $i++) { $index = $appearance_indices[1][$i]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } echo "
"; // Word 3's sentences echo "
"; if( count($appearance_indices[2]) > 10 ) { // Using the 10 random indices from $random_indices for($i = 0; $i < 10; $i++) { // Find the randomly chosen index of the appearances_indices table $appearance_lookup_index = $random_indices[2][$i]; // Find the lines table index stored in the appearances_indices table $index = $appearance_indices[2][$appearance_lookup_index]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } else { for($i = 0; $i < count($appearance_indices[2]); $i++) { $index = $appearance_indices[2][$i]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } echo "
"; // Word 4's sentences echo "
"; if( count($appearance_indices[3]) > 10 ) { // Using the 10 random indices from $random_indices for($i = 0; $i < 10; $i++) { // Find the randomly chosen index of the appearances_indices table $appearance_lookup_index = $random_indices[3][$i]; // Find the lines table index stored in the appearances_indices table $index = $appearance_indices[3][$appearance_lookup_index]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } else { for($i = 0; $i < count($appearance_indices[3]); $i++) { $index = $appearance_indices[3][$i]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } echo "
"; // Word 5's sentences echo "
"; if( count($appearance_indices[4]) > 10 ) { // Using the 10 random indices from $random_indices for($i = 0; $i < 10; $i++) { // Find the randomly chosen index of the appearances_indices table $appearance_lookup_index = $random_indices[4][$i]; // Find the lines table index stored in the appearances_indices table $index = $appearance_indices[4][$appearance_lookup_index]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } else { for($i = 0; $i < count($appearance_indices[4]); $i++) { $index = $appearance_indices[4][$i]; echo "

".($i + 1).". ".$lines[$index + 10]."

"; } } echo "
"; echo "
"; ?>