bucket_list_friends - 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 bucket_list_friends.php

  1. <?php
  2.  
  3. $getal = readline("Hoeveel vrienden zal ik vragen om hun droom?" . PHP_EOL);
  4. if (!is_numeric($getal)) {
  5.     exit("'$getal'is geen getal, probeer het opnieuw" . PHP_EOL);
  6. } else {
  7. echo "Wat is jou naam?" . PHP_EOL;
  8. echo "Wat is jou droom?" . PHP_EOL;
  9.  
  10. $vriend_1 = readline('');
  11. $vriend_1 = array()
  12.  
  13. $dromen[$i] = ['naam' => $naam, 'droom' => $droom];
  14.  
  15. for ($i = 0; $i < $getal; $i++) {
  16.     $dromen[] = readline("Wat is jou droom?" . PHP_EOL);
  17. }
  18.  
  19. echo $naam . "heeft dit als zijn droom:" . $droom . PHP_EOL;
  20.  
  21. for ($i = 0; $i < $getal; $i++) {
  22.     echo $droom[$i] . PHP_EOL;
  23. }
File Description
  • bucket_list_friends
  • PHP Code
  • 20 Sep-2021
  • 602 Bytes
You can Share it: