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.



Your result can be seen below.

Result of php executing





Full code of Dromenvanger goed 1.php

  1. <?php
  2. $hoeveel = readline('Hoeveel vrienden zal ik vragen om hun droom? ');
  3. if (is_numeric($hoeveel)) {
  4.     for ($x = 0; $x < $hoeveel; $x++) {
  5.         $namen = readline('Wat is jouw naam?: ');
  6.         $vrienden[] = $namen;
  7.         $aantal = readline('Hoeveel dromen ga jij opgeven? '); 
  8.         if (is_numeric($aantal)) {
  9.             for ($i = 0; $i < $aantal; $i++) {
  10.                 $droom = readline('Wat is jouw droom?: ');
  11.                 $vrienden[$namen][] = $droom;
  12.             }
  13.         } else {
  14.             exit($aantal . 'is geen getal, probeer het opnieuw');
  15. }
  16. }        
  17. } else {
  18.     exit($hoeveel . 'is geen getal, probeer het opnieuw');
  19. }
  20. print_r ($vrienden);
  21.  
  22.  
File Description
  • Dromenvanger goed 1
  • PHP Code
  • 23 Sep-2021
  • 676 Bytes
You can Share it: