title: Fake Latin Generator PHP
body: <p><em>I am not asking for homework help, just a push in the right direction please!</em></p>
  
  <p>Recently started learning PHP at university and one of the exercises was to create a fake Latin generator.</p>
  
  <p>The parameters had to be as follow:</p>
  
  <p>Every word has a 1 in 10 chance of having a comma placed after it.<br/>
  Every sentence has to contain between 8 and 25 words.<br/>
  Every paragraph has to contain between 3 and 7 sentences.<br/>
  Every page has to contain between 3 and 5 paragraphs.<br/>
  Every starting sentence must start with capital letter.<br/></p>
  
  <p>My code as follow:</p>
  
  <pre><code>&lt;?php
  $latin_words = array("lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "sed", "diam", "nonummy", "nibh", "euismod", "tincidunt", "ut",
                       "laoreet", "dolore", "magna", "aliquam", "erat", "volutpat", "ut", "wisi", "enim", "ad", "minim", "veniam", "quis", "nostrud",
                       "exerci", "tation", "ullamcorper", "suscipit", "lobortis", "ni", "sl", "ut", "aliquip", "ex", "ea", "commodo", "consequat", "duis", "autem",
                       "vel", "eum", "iriure", "dolor", "in", "hendrerit", "in", "vulputate", "velit", "esse", "molestie", "consequat", "vel", "illum", "dolore", "eu",
                       "feugiat", "nulla", "facilisis", "at", "vero", "eros", "et", "accumsan", "et", "iusto", "odio", "dignissim", "qui", "blandit", "praesent", "luptatum", "zzril",
                       "delenit", "augue", "duis", "dolore", "te", "feugait", "nulla", "facilisi", "ut", "wisi", "enim", "ad", "minim", "veniam", "quis", "nostrud", "exerci", "tation", "ullamcorper",
                       "suscipit", "lobortis", "nisl", "ut", "aliquip", "ex", "ea", "commodo", "consequat", "duis", "autem", "vel", "eum", "iriure", "dolor", "in", "hendrerit", "in", "vulputate",
                       "velit", "esse", "molestie", "consequat", "vel", "illum", "dolore", "eu", "feugiat", "nulla", "facilisis", "at", "vero", "eros", "et", "accumsan", "et", "iusto", "odio",
                       "dignissim", "qui", "blandit", "praesent", "luptatum", "delenit", "augue", "duis", "dolore", "te", "feugait", "nulla", "facilisi");
  
  $max = count($latin_words);
  for($pagelen = rand(3,5); $pagelen != 6; $pagelen++)
  {
      $word = rand(0,$max - 1);
      for($para = rand(3,7); $para != 8; $para++)
      {
          echo ucfirst($latin_words[$word]);
          for($sentlen = rand(8,25); $sentlen != 26; $sentlen++)
          {
              $word = rand(0,$max - 1);
              echo " " . $latin_words[$word];
              for($comchance = rand(1,10); $comchance == 10; $comchance++)
              {
                  echo ",";
              }
          }
          echo ". ";
      }
      echo "&lt;br/&gt;&lt;br/&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p><li>I thought i had got it all right until i started noticing that i was sometimes getting only 1 paragraph per page.</li><br/>
  <li>I am also not sure how to stop a comma being followed by a full stop at the end of a sentence - i read a switch might work but we hadn't covered this so i was wary about adding one in.</li></p>
  
  <p>Any push in the right directions would be greatly appreciated!</p>