fork(2) download
  1. <?php
  2. $mars = array ('How big is Mars?', 'How many moons does Mars have?', 'How far away is Mars?', 'What is the highest point on Mars?');
  3. $jupiter = array ('How big is Jupiter?', 'How many moons does Jupiter have?', 'How far away is Jupiter?', 'What is the highest point on Jupiter?');
  4. $earth = array ('How big is Earth?', 'How many moons does Earth have?', 'How far away is Earth?', 'What is the highest point on Earth?');
  5. $sun = array ('How big is the Sun?', 'How many moons does the Sun have?', 'How far away is the Sun?', 'What is the highest point on the Sun?');
  6.  
  7. $all = array($mars, $jupiter, $earth, $sun);
  8. shuffle($all);
  9.  
  10. function createList($a)
  11. {
  12. echo "<ul>";
  13. $count = 1;
  14.  
  15. foreach ($a as $array)
  16. {
  17. $questions = count($array);
  18. $idquestion = rand(0, $questions-1);
  19. echo "<li>" . $array[$idquestion] . "</li>";
  20. if ($count++ >= 3) {
  21. break;
  22. }
  23. }
  24. echo "</ul>";
  25. }
  26.  
  27. createList($all);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
<ul><li>How far away is Jupiter?</li><li>What is the highest point on Mars?</li><li>How big is Earth?</li></ul>