Advertisement
HristoBaychev

indexRacing

Apr 14th, 2023
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2. declare(strict_types=1);
  3. require_once 'carRacing.php';
  4.  
  5. $pilots = [];
  6. $count = 0;
  7. while (count($pilots) < 2){
  8.     if (isset($_GET["start"])) {
  9.         $racerName = $_GET["racer_one"];
  10.         if (in_array($racerName, array_column($pilots, 'pilot'))) {
  11.             $racerName.= strval(++$count);
  12.         }
  13.         $newRacer = new carRacing($racerName, $_GET["model_car"], (int)$_GET["speed"], (int)$_GET["box_time"]);
  14.         array_push($pilots, $newRacer);
  15.     }
  16.     var_dump($pilots);
  17. }
  18. ?>
  19. <!DOCTYPE html>
  20. <html>
  21.     <form>
  22.         Name racer:<input type="text" name="racer_one" /></br>
  23.         Car racer:<input type="text" name="model_car" /></br>
  24.         Speed racer:<input type="number" name="speed" /></br>
  25.         Time in box:<input type="number" name="box_time" /></br>
  26.         <input type="submit" name="start" value="start racing" />
  27.     </form>
  28. </html>
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement