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. $amountfriends = readline( 'Hoeveel vrienden zal ik om hun dromen vragen ? ' . PHP_EOL);
  3. if (is_numeric($amountfriends) === false)  { 
  4.     exit($amountfriends . ”is geen getal” );
  5. }
  6. $friends = [];
  7. for ($i = 0; $i < $amountfriends; $i++) { 
  8.     $yourname = readline('Wat is jouw naam ? ' . PHP_EOL);
  9.     $dreams = [];
  10.     $dreams .= $yourname;
  11.     $numberdreams = readline(“Hoeveel dromen ga je opgeven?” . PHP_EOL);
  12.     if (is_numeric($numberdreams) === false) {
  13.         exit($numberdreams . “is geen geldig getal”);
  14. }
  15.     for ($j = 0; $j < $numberdreams; $j++) {
  16.         $yourdream = readline(“Wat is je droom?” . PHP_EOL);
  17.         foreach ($friends as $yourname);
  18.         echo($yourname . ' heeft als droom: ' . $yourdream);
  19.         echo(PHP_EOL);
  20. }
  21.  
File Description
  • bucket_list_friends
  • PHP Code
  • 20 Sep-2021
  • 774 Bytes
You can Share it: