This is my coding for looping through an array and assigning the array with link paths.The problem is the shuffle function.
I need to shuffle the array according to section.Section 1 it works pretty well.
But the problem is that in the section 2a it only shuffle until the 8th element in that section.The rest element in the array is not even assign a shuffled value.
I would very much appreciate you all out there to give some help.
Thanks!

<?php
//Assigning each path into array without randomizing

function section($min,$max){
global $Rand_ques;
for($i=$min,$k=0;$k<=$max-$min;$i++,$k++){

   $Rand_ques[$i]=("path$i");

   }

}

//Assigning path to be randomize into array
function shuffle_section($min,$max){
global $Rand;
global $Rand_ques;
srand((double) microtime()*10000000);
for($i=$min,$k=0;$k<=$max-$min;$i++,$k++){ //Assign a temp array to store
$Rand_temp[$i]=$Rand_ques[$i]; //the non randomized path

}
    shuffle($Rand_temp);
    for($i=$min,$k=0;$k<=$max-$min;$i++,$k++){
        $Rand[$i]=$Rand_temp[$i];         //Assign randomized path to array
     echo "$Rand_temp[$i]";

}

}

section($min=0,$max=14); //section1=question 1-15
section($min=15,$max=37); //section2a=question 16-38
section($min=38,$max=39); //section2b=question 39-40
section($min=40,$max=49); //section3=question 41-50

shuffle_section($min=0,$max=14); //section1=question 1-15
shuffle_section($min=15,$max=37); //section2a=question 16-38
shuffle_section($min=38,$max=39); //section2b=question 39-40
shuffle_section($min=40,$max=49); //section3=question 41-50

    why not:
    void shuffle (array array)
    ?

    it's a php function...
    so u dont need to shuffle sections, u can shuffle the entire array...

      Write a Reply...