Geography: countries and their capitals
- Given is an associative array
$capitals with countries (keys) and their capitals
(values)
- Generate a random country
- Add a select list with all possible answers (capitals sorted alphabetically)
- Submit your answer (to the same page) when clicking the button, and show some feedback:
- When no capital is selected: Please choose a city! in a
div with
class box-warning
- When a wrong capital is selected: "Wrong: the correct answer is ... in a
div with class box-warning
- When the correct capital is selected: Correct! in a
div with
class box-info
Tips
- The random country can be generated with the function
array_rand(), which generates a
random key of
an array, on the given array $capitals
- Use a hidden field (
type="hidden") to pass the value of this random country
along with your GET or POST request