topo - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of topo.php
- <?php
- $topo = [
- 'Japan' => 'Tokyo',
- 'UK' => 'London',
- 'Egypt' => 'Cairo',
- 'Mexico' => 'Mexico stad',
- 'USA' => 'Washington D.C.',
- 'India' => 'New Delhi',
- 'Zuid-Korea' => 'Seoul',
- 'China' => 'Peking',
- 'Nigeria' => 'Abuja',
- 'Argentina' => 'Buenos Aires',
- ];
- $result = [];
- foreach ($topo as $country => $city) {
- echo "Wat is de hoofdstad van $country?" . PHP_EOL;
- $input = readline('-> ');
- }
- if ($input != ($city)) {
- echo "Helaas, $input is niet de hoofdstad van $country" . PHP_EOL;
- echo "Het correcte anwoord is $city" . PHP_EOL;
- } else {
- ($result[$country] == $input);
- echo "Correct" . PHP_EOL;
- }
- $good = '0';
- foreach ($topo as $country => $city) {
- if ($city == $result[$country]) {
- $good++;
- }
- echo "je hebt $good van de 10 goed" . PHP_EOL;
- }