How Would I randomize this Array So that when i use a for each loop it would it would switch index 0 with key 1 and to randomize the order
iv tried $variable= array_rand($varialbe,count($variavle)) but it prints out
0 => int 0
1 => int 1
2 => int 2
3 => int 3
4 => int 4
foreach ($variable as $key)
array (size=10)
0 =>
object(stdClass)[25]
public 'id' => string '24' (length=2)
public 'course_name' => string 'Office Automation' (length=17)
public 'test_name' => string 'Test 2' (length=6)
public 'total_questions' => string '10' (length=2)
public 'duration' => string '20' (length=2)
public 'total_marks' => string '20' (length=2)
public 'question' => string 'Question1' (length=9)
public 'option1' => string 'ans1' (length=4)
public 'option2' => string 'ans2' (length=4)
public 'option3' => string 'ans3' (length=4)
public 'option4' => string 'ans4' (length=4)
public 'ans' => string 'D' (length=1)
public 'count' => string '1' (length=1)
1 =>
object(stdClass)[26]
public 'id' => string '25' (length=2)
public 'course_name' => string 'Office Automation' (length=17)
public 'test_name' => string 'Test 2' (length=6)
public 'total_questions' => string '10' (length=2)
public 'duration' => string '20' (length=2)
public 'total_marks' => string '20' (length=2)
public 'question' => string 'Question2' (length=9)
public 'option1' => string 'ans1' (length=4)
public 'option2' => string 'ans2' (length=4)
public 'option3' => string 'ans3' (length=4)
public 'option4' => string 'ans4' (length=4)
public 'ans' => string 'A' (length=1)
public 'count' => string '2' (length=1)
2 =>
object(stdClass)[27]
public 'id' => string '26' (length=2)
public 'course_name' => string 'Office Automation' (length=17)
public 'test_name' => string 'Test 2' (length=6)
public 'total_questions' => string '10' (length=2)
public 'duration' => string '20' (length=2)
public 'total_marks' => string '20' (length=2)
public 'question' => string 'Question3' (length=9)
public 'option1' => string 'ans1' (length=4)
public 'option2' => string 'ans2' (length=4)
public 'option3' => string 'ans3' (length=4)
public 'option4' => string 'ans4' (length=4)
public 'ans' => string 'B' (length=1)
public 'count' => string '3' (length=1)
How Would i do That
Need to just randomize the order so that when it prints it will print a new order everytime
The array stores question and question option in the keys/indexes
Aucun commentaire:
Enregistrer un commentaire