Advertisement
Guest User

index.php

a guest
May 24th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. // $str1 = '1,2,3,4,5';
  4. // $arr = explode(',',$str1);
  5. // foreach($arr as $i)
  6. // echo($i.'<br>');
  7. $num = 4;
  8. $num2 = 3;
  9. $cars = array
  10. (
  11. array("Volvo","first_second_third_fourth","a"),
  12. array("BMW","hanabi_claude_yi sun shin_granger","b"),
  13. array("Saab","third_second_third_fourth","c"),
  14. array("Land Rover","fourth_second_third_fourth","d")
  15. );
  16. echo "<form method='POST'>";
  17. for ($x = 0 ; $x<$num; $x++) {
  18. echo "<p><b>Question".$cars[$x][0]."</b></p>";
  19. $choices = $cars[$x][1];
  20. $arr = explode('_',$choices);
  21. echo "<ol type='A'>";
  22. foreach ($arr as $id => $value) {
  23. $y = $id+1;
  24. echo "<li><input type='radio' name='answer[$x]' value='".chr(64 + $y)."'>$value</li>";
  25. }
  26. echo "</ol>";
  27.  
  28. echo "<br><br><br>";
  29.  
  30. }
  31. echo "<input type= 'submit' name='submit' value='Submit'></form>";
  32.  
  33. if (isset($_POST['submit'])) {
  34. echo "<pre>";
  35. var_dump($_POST['answer']);
  36. echo "</pre>";
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement