Forum Moderators: coopster
I have an array with x number of words in it (one word per array item) and I'm trying to print them to the page in paragraphs. Randomly picking the words and the paragraph size.
This code just prints the same paragraph but getting longer each time. I just can't get my head round this and would really appreciate some help....
[pre]
$start=1;
while($end<sizeof($words)) {
$limit=$start+100;
srand((float) microtime() * 10000000);
$end=rand($start, $limit);
$newarray=array_slice($words, $start, $end);
foreach($newarray as $key => $val) {
$para.=$val;
}
$start=$end;
$output.="\n<p>$para</p>\n";
}
print($output);
[/pre] Many thanks...
Nick
It increases by 100 each time.
The paragraphs should be of varying length.
The idea is to make paragraphs out of the words array of varying lenght with random selections from the words array. (but only as long as there are no more words to fetch from the array).
With me? ;)
Thanks Jatar...
Nick