2_kr - 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 2_kr.php

  1. <!DOCTYPE html>
  2. <html lang="ru">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Таблица степеней</title>
  7.     <style>
  8.         table {
  9.             border-collapse: collapse;
  10.             width: 50%;
  11.             margin: 20px;
  12.         }
  13.         table, th, td {
  14.             border: 1px solid black;
  15.         }
  16.         th, td {
  17.             padding: 10px;
  18.             text-align: center;
  19.         }
  20.     </style>
  21. </head>
  22. <body>
  23.  
  24.     <?php
  25.         // можно и рандомно, но тут конкретно не указывается
  26.         $array1 = [5, 4, 4, 3, 6];
  27.         $array2 = [7, 3, 5, 2, 4];
  28.  
  29.         echo "<h2>Таблица степеней</h2>";
  30.         echo "<table>";
  31.         echo "<tr><th>Число из массива 1</th><th>Число из массива 2</th><th>Результат</th></tr>";
  32.  
  33.         for ($i = 0; $i < count($array1); $i++) {
  34.             $result = pow($array1[$i], $array2[$i]);
  35.             echo "<tr><td>{$array1[$i]}</td><td>{$array2[$i]}</td><td>{$result}</td></tr>";
  36.         }
  37.  
  38.         echo "</table>";
  39.     ?>
  40.  
  41. </body>
  42. </html>
  43.  
File Description
  • 2_kr
  • PHP Code
  • 14 Feb-2024
  • 1.13 Kb
You can Share it: