Dromenvanger goed 1 - 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 Dromenvanger goed 1.php
- <?php
- $hoeveel = readline('Hoeveel vrienden zal ik vragen om hun droom? ');
- if (is_numeric($hoeveel)) {
- for ($x = 0; $x < $hoeveel; $x++) {
- $namen = readline('Wat is jouw naam?: ');
- $vrienden[] = $namen;
- $aantal = readline('Hoeveel dromen ga jij opgeven? ');
- if (is_numeric($aantal)) {
- for ($i = 0; $i < $aantal; $i++) {
- $droom = readline('Wat is jouw droom?: ');
- $vrienden[$namen][] = $droom;
- }
- } else {
- exit($aantal . 'is geen getal, probeer het opnieuw');
- }
- }
- } else {
- exit($hoeveel . 'is geen getal, probeer het opnieuw');
- }
- print_r ($vrienden);