Hi
I am writing code that randomly selects a word from one text file and then another word from another text file and puts those words together to make a sentence.
The code below is what i have done so far and it works fine.
My problem is that i want to be able to expand this code so that eventually it selects up to 20 words or more but i want to avoid repeating the same code again and aganin with only minor changes.
I figured a function that can be called many times to generate values for the $result variable will be the best way to do this but i have not successfully been able to write one.
Help please????
<?php
$word1 = file('words/first_word/choice1.txt');
$n = count($word1);
$random1 = rand(0, ($n - 1));
$word2 = file('words/second_word/choice2.txt');
$n = count($word2);
$random2 = rand(0, ($n - 1));
$results = ('<p>' . $word1[$random1] .' '. $word2[$random2] '</p>');
?>