Advertisement
Guest User

Untitled

a guest
Nov 12th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <?php
  2. $columns = ["#", "-#", "x", "/", "%"];
  3. $rows = 10;
  4. $sums = [];
  5. echo("
  6. <table>
  7. <tr>
  8. ");
  9. for ($i = 0; $i < count($columns); $i++){
  10. echo("<th>".$columns[$i]."</th>");
  11. }
  12. echo("<tr>");
  13. $cells = [];
  14. for ($i = 1; $i <= $rows; $i++){
  15. echo("<tr>");
  16. for ($v = 0; $v < count($columns); $v++){
  17. if ($v == 0){
  18. echo("<td>".$i."</td>");
  19. $cells[$v] = $i;
  20. }
  21. elseif ($v == 1){
  22. echo("<td>".($rows - $i + 1)."</td>");
  23. $cells[$v] = $rows - $i + 1;
  24. }
  25. elseif ($v == 2){
  26. echo("<td>".($cells[0] * $cells[1])."</td>");
  27. $cells[$v] = $cells[0] * $cells[1];
  28. }
  29. elseif ($v == 3){
  30. echo("<td>".($cells[0] / $cells[1])."</td>");
  31. $cells[$v] = $cells[0] / $cells[1];
  32. }
  33. elseif ($v == 4){
  34. echo("<td>".($cells[0] % $cells[1])."</td>");
  35. $cells[$v] = $cells[0] % $cells[1];
  36. }
  37. @$sums[$v] += @$cells[$v];
  38. }
  39. echo("</tr>");
  40. }
  41. echo("<tr>");
  42. for ($i = 0; $i < count($sums); $i++){
  43. echo("<th>".$sums[$i]."</th>");
  44. }
  45. echo(
  46. "<tr>
  47. </table>
  48. ");
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement