YavorGrancharov

Numbers from 1 to N

Dec 2nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>First Steps Into PHP</title>
  6.  
  7. </head>
  8. <body>
  9. <form>
  10.     N: <input type="text" name="num"/>
  11.     <input type="submit"/>
  12. </form>
  13. <?php
  14. if (isset($_GET['num'])) {
  15.     $set = [];
  16.     $n = intval($_GET['num']);
  17.     for ($x = 1; $x <= $n; $x++) {
  18.         $set[$x] = $x;
  19.     }
  20.     echo implode(" ", $set);
  21. }
  22. ?>
  23. </body>
  24. </html>
Add Comment
Please, Sign In to add comment