take between 5 and 8 phrases wich are the shortest in characters. then for each one of those i need to do between 5 and 8 phrases then for each of those i need to do between 5 and 8 phrases and so on until im out of phrases. now i made it for the base phrases but i dont really know how to keep looping and adding on for the other levels of the array. im not really sure how to go about doing anything but making the base of it. here is what i have so far
Code: Select all
function make_lists($words)
{
$temp = array_map('strlen',$words);
asort($temp);
$array = array();
foreach($temp as $key => $val)
{
$array[$key] = $words[$key];
}
//$array is now the list of words sorted by length
$num = rand(5, ;
$num2 = $num*2;
$num2 = ($num2 > count($array) ? count($array) : $num2);
$arrnum = array();
while (count($arrnum) < $num)
{
$rand = rand(1,2);
if ($rand == 1)
{
$rand = rand(1, $num2);
if (!in_array($rand, $arrnum))
$arrnum[] = $rand;
}
}
for($i=0; $i<count($arrnum); $i++)
{
$new[] = $array[$arrnum[$i]];
unset($array[$arrnum[$i]]);
}
//$new is a array of the base words for the changed array
//shuffle up the old array and reset the keys
$array = ashuffle($array);
//problems here -> loop till out of array elements or till you have between 5-8 links for the 1st page
return $new;
}