{ $resultArray = array(); $i = 0; foreach ($listOfWords as $val) { if ($i < $numberOfWords) { $num = rand(1, 6); $resultArray[$i] = $listOfWords[$num]; $i++; } } return $resultArray; } ?> <ol> <?php $result = getWordsByNumber($file_explode, 3); foreach ($result as $val) { $array = explode("\t", $val); ?> <li><?php echo $array[0]; ?> - <?php echo $array[1]; ?> </li> <?php } ?> </ol>
<div class="section"> <h2>Today's words</h2> <!-- Ex. 2: Today’s Words & Ex 6: Query Parameters --> <?php function getWordsByNumber($listOfWords, $numberOfWords) { $resultArray = array(); foreach ($listOfWords as $result) { $resultArray[] = $result; } shuffle($resultArray); $resultArray = array_slice($resultArray, 0, $numberOfWords); return $resultArray; } $numberOfWords = rand(1, 7); $todaysWords = getWordsByNumber($lines, $numberOfWords); ?> <ol> <?php foreach ($todaysWords as $element) { ?> <li><?php echo $element; ?> </li> <?php } ?> <!-- <li>Apple - An apple is a round fruit with smooth green, yellow, or red skin and firm white flesh.</li> <li>Computer - A computer is an electronic machine that can store and deal with large amounts of information.</li>
function getWordsByNumber($listOfWords, $numberOfWords) { $resultArray = array(); // implement here. foreach ($listOfWords as $key => $value) { array_push($resultArray, array($key, $value)); } shuffle($resultArray); $r = array_slice($resultArray, 0, $numberOfWords); return $r; } $numberOfWords = $_GET["number_of_words"]; if (!isset($numberOfWords) || strlen($numberOfWords) == 0) { $numberOfWords = 3; } $todaysWords = getWordsByNumber($dictionary, $numberOfWords); ?> <ol> <?php foreach ($todaysWords as $tWord) { ?> <li><?php echo $tWord[0]; ?> - <?php echo $tWord[1]; ?> </li> <?php } ?>
} else { if ($numberOfWords < 0) { $numberOfWords = 0; } } shuffle($listOfWords); while ($numberOfWords != 0) { array_push($resultArray, array_pop($listOfWords)); $numberOfWords--; } return $resultArray; } ?> <ol> <?php $todaysWords = getWordsByNumber($lines, $number_of_words); foreach ($todaysWords as $key => $value) { $word = explode("\t", $value); ?> <li><?php echo $word[0] . " - " . $word[1]; ?> </li> <?php } ?> </ol> </div> <div class="section"> <h2>Searching Words</h2> <!-- Ex. 3: Searching Words & Ex 6: Query Parameters -->
<!-- Ex. 2: Today’s Words & Ex 6: Query Parameters --> <ol> <?php function getWordsByNumber($listOfWords, $numberOfWords) { $resultArray = array(); $resultArray = array_slice($listOfWords, $numberOfWords); return $resultArray; } ?> <?php $ran_int = $_GET["number_of_words"]; if (!isset($ran_int) or $ran_int == "") { $ran_int = 3; } $resultArray = getWordsByNumber($file, $ran_int); foreach ($resultArray as $line) { ?> <li><?php echo $line; ?> </li> <?php } ?> </ol> </div> <div class="section"> <h2>Searching Words</h2> <!-- Ex. 3: Searching Words & Ex 6: Query Parameters --> <?php
$temparr = array(); foreach($listOfWords as $row) { array_push($temparr, $row); } shuffle($temparr); for($i=0; $i < $numberOfWords; $i++) { $var = strtok($temparr[$i], "\t"); $var .= ' - '; $var .= strtok("\t"); array_push($resultArray, $var); } return $resultArray; } $todaysWords = getWordsByNumber($line, 3); ?> <ol> <?php foreach($todaysWords as $row) {?> <li><?=$row;?></li> <?php } ?> </ol> </div> <div class="section"> <h2>Searching Words</h2> <!-- Ex. 3: Searching Words & Ex 6: Query Parameters --> <?php function getWordsByCharacter($listOfWords, $startCharacter){
</p> </div> <div class="article"> <div class="section"> <h2>Today's words</h2> <!-- Ex. 2: Today’s Words & Ex 6: Query Parameters --> <?php function getWordsByNumber($listOfWords, $numberOfWords) { $resultArray = array(); // implement here. $lists = $listOfWords; $resultArray = array_rand($lists); return $resultArray; } foreach (getWordsByNumber($lines, 4) as $result) { print "{$result}"; } ?> <ol> <li>Apple - An apple is a round fruit with smooth green, yellow, or red skin and firm white flesh.</li> <li>Computer - A computer is an electronic machine that can store and deal with large amounts of information.</li> <li>Graduate - A graduate is a person who has successfully completed a degree at a university or college and has received a certificate that shows this.</li> </ol> </div> <div class="section"> <h2>Searching Words</h2> <!-- Ex. 3: Searching Words & Ex 6: Query Parameters --> <?php function getWordsByCharacter($listOfWords, $startCharacter) {
{ $resultArray = array(); foreach ($listOfWords as $temp) { if (substr($startCharacter, 0, 1)) { $resultArray = $temp; } } return $resultArray; } ?> <p> Words that started by <strong>'C'</strong> are followings : </p> <ol> <?php echo getWordsByCharacter(getWordsByNumber($lines, $numberOfWords), $startCharacter); foreach (getWordsByCharacter($getWordsByNumber, $startCharacter) as $searchedWords) { ?> <li><?php echo $searchedWords; ?> </li> <?php } ?> </ol> </div> <div class="section"> <h2>List of Words</h2> <!-- Ex. 4: List of Words & Ex 6: Query Parameters -->
// implement here. return $resultArray; } ?> <?= $random ?> <?php $abc = $filename; shuffle($abc); ?> <?= $abc[2] ?> <ol> <?php $name = getWordsByNumber($filename,$random); ?> <?php foreach($name as $aaa) { ?> <li><?= $name ?></li> <? } ?> </ol> </div> <div class="section"> <h2>Searching Words</h2> <!-- Ex. 3: Searching Words & Ex 6: Query Parameters --> <?php function getWordsByCharacter($listOfWords, $startCharacter){ $resultArray = array(); // implement here.