rnd_from_array( array( 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18, 1,1,1, 2,2,2,2,2, 3,3,3,3,3, 4,4,4,4,4,4,4,4, 7,7,7, 9, 12,12,12, 14,14, 16,16,16, 17, 19,19 ) ); // $titleTemplateNum = 1; // ** build a title from the title type: $titleStr = ""; switch ($titleTemplateNum) { // 1. The case 1: $titleStr = $this->rnd_from_array($dwtd_AdversariesSingular) . " " . $this->rnd_from_array($dwdt_SuffAdventAct); break; // 2. The of case 2: $titleStr = "The " . $this->rnd_from_array($dwdt_PrefAdventAct) . " of " . $this->lc_the($this->rnd_from_array($dwtd_AdversariesPlural)); break; // 3. The of case 3: $titleStr = "The " . $this->rnd_from_array($dwdt_PrefAdventAct) . " of " . $this->rnd_from_array($dwdt_NamedPlace); break; // 4. to the/of the/and the .. but only 'of the' works consistently case 4: $titleStr = $this->rnd_from_array($dwdt_ThreatConcept) . " of " . $this->lc_the($this->rnd_from_array($dwtd_AdversariesPlural)); break; // 5. to/of case 5: $titleStr = "The " . $this->remove_the($this->rnd_from_array($dwdt_AdventTypePrefix)) . " " . $this->lc_the($this->rnd_from_array($dwdt_ThreatConcept)); break; // 6. The case 6: $titleStr = "The " . $this->remove_the($this->rnd_from_array($dwdt_ThreatConcept)) . " " . $this->rnd_from_array($dwdt_AdventTypeSuffix); break; // 7. The of case 7: $titleStr = "The " . $this->rnd_from_array($dwdt_AdversaryType) . " of " . $this->lc_the($this->rnd_from_array($dwdt_ThreatConcept)); break; // 8. The case 8: $titleStr = "The " . $this->remove_the($this->rnd_from_array($dwdt_ThreatConcept)) . " " . $this->rnd_from_array($dwdt_AdventAspect); break; // 9. The case 9: $titleStr = "The " . $this->remove_the($this->rnd_from_array($dwdt_NamedPlace)) . " " . $this->rnd_from_array($dwdt_AdventAspect); break; // 10. The from case 10: $titleStr = "The " . $this->rnd_from_array($dwdt_AdversaryType) . " from " . $this->lc_the($this->rnd_from_array($dwdt_AdventPlace)); break; // 11. from case 11: $titleStr = $this->rnd_from_array($dwdt_AbsAdventThing) . " from " . $this->lc_the($this->rnd_from_array($dwdt_AdventPlace)); break; // 12. The case 12: $titleStr = "The " . $this->rnd_from_array($dwdt_StrangeQuality) . " " . $this->remove_the($this->rnd_from_array($dwdt_AdventPlace)); break; // 13. The of case 13: $titleStr = $this->rnd_from_array($dwdt_AdventPlace) . " of " . $this->rnd_from_array($dwdt_ofStrangeQuality); break; // 14. The case 14: $titleStr = "The " . $this->rnd_from_array($dwdt_StrangeQuality) . " " . $this->rnd_from_array($dwdt_SuffAdversaryType); break; // 15. case 15: $titleStr = $this->rnd_from_array($dwdt_AdversaryTypePoss) . " " . $this->rnd_from_array($dwdt_AbsAdventThing); break; // 16. The case 16: $titleStr = "The " . $this->rnd_from_array($dwdt_StrangeQuality) . " " . $this->rnd_from_array($dwdt_SuffAdventAct); break; // 17. The of case 17: $titleStr = "The " . $this->rnd_from_array($dwdt_AdversaryType) . " of " . $this->lc_the($this->rnd_from_array($dwdt_AdventPlace)); break; // 18. The in Space case 18: $titleStr = $this->rnd_from_array($dwdt_AdventPlace) . " in Space"; break; // 19. case 19: $numTitlesType = rand(1,4); switch ($numTitlesType) { case 1: $titleStr = "Galaxy " . rand(1,1000); break; case 2: $numbersArray = array( "One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten" ); $titleStr = $this->rnd_from_array($numbersArray) . " to Doomsday"; break; case 3: $numbersArray = array( "Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth" ); $titleStr = "The " . $this->rnd_from_array($numbersArray) . " Planet"; break; case 4: $numbersArray = array( "Two","Three","Four","Five","Six","Seven","Eight" ); $titleStr = "The " . $this->rnd_from_array($numbersArray) . " Doctors"; break; } break; } if ($this->report) { $titleStr.= " (Type: " . $titleTemplateNum . ")"; } return $titleStr; } public function get_titles($numTitles) { // return an array of multiple titles: $titlesArray = array(); for ($i = 0; $i < $numTitles; $i++) { // pick a title template: $titlesArray[] = $this->get_title(); } return $titlesArray; } private function rnd_from_array($arr) { // return random element from the array: return $arr[array_rand($arr)]; } private function lc_the($inStr) { // if the first word in inStr is 'The', // makes it a lowercase 'the' $retStr = $inStr; if (substr($retStr, 0,4) == "The ") { $retStr = "the " . substr($retStr, 4); } return $retStr; } private function remove_the($inStr) { // removes a 'The' if it's there $retStr = $inStr; if (substr($retStr, 0,4) == "The ") { $retStr = substr($retStr, 4); } return $retStr; } } ?>