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

Name: bucket_list_friends aangepast fullscreencopydownloadembedprint


Your result can be seen below.

Result of php executing





Full code of bucket_list_friends aangepast .php

  1. <?php
  2.  
  3. $input = readline("Hoeveel vrienden zal ik vragen om hun droom?" . PHP_EOL);
  4. if (is_numeric($input) == false) {
  5.     exit("($input) is geen getal, probeer het opnieuw");
  6. }
  7.  
  8. $array = [];
  9.  
  10. for ($i = 1; $i <= ($input); $i++) {
  11.     $naam_key =readline("Wat is jouw naam?");
  12.     $droom_value = readline("Wat is jouw droom?");
  13.  
  14.     $array += [$naam_key => $droom_value];
  15. }
  16.  
  17. foreach ($array as $key => $value) {
  18.     echo $key . ' heeft dit als droom: ' . $value . PHP_EOL;
  19. }
  20. ?>
File Description
  • bucket_list_friends aangepast
  • PHP Code
  • 20 Sep-2021
  • 476 Bytes
You can Share it: