<!doctype html>
<html lang="pl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Zadanie P51c - Funkcja działająca na tablicach</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
<header>
    <h1>Zadanie P51-c</h1>
    <h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
    <?php
    $tab = array(
        array(1,7,3,0,1),
        array(1,0,5,7,4),
        array(1,5,3,2,0),
        array(0,1,2,3,4),
        array(1,2,3,4,5)
    );
    $m = 3;
    function dzialanieNaTablicy($tab, $m) {
        echo "<table>";
        for ($i = 0; $i < count($tab); $i++) {
            echo "<tr>";
            for ($j = 0; $j < count($tab[$i]); $j++) {
                if ($tab[$i][$j] > $m) {
                    echo "<td>" . $tab[$i][$j] . "</td>";
                } else {
                    echo "<td>" . $tab[$i][$j] . "</td>";
                }
            }
            echo "</tr>";
        }
        echo "</table>";
        for ($i = 0; $i < count($tab); $i++) {
            for ($j = 0; $j < count($tab[$i]); $j++) {
                $tab[$i][$j] *= $m;
                if ($tab[$i][$j] == 0) {
                    $tab[$i][$j] = 1;
                }
            }
        }
        echo "<hr>";
        echo "<table>";
        for ($i = 0; $i < count($tab); $i++) {
            echo "<tr>";
            for ($j = 0; $j < count($tab[$i]); $j++) {
                if ($tab[$i][$j] > $m) {
                    echo "<td>" . $tab[$i][$j] . "</td>";
                } else {
                    echo "<td>" . $tab[$i][$j] . "</td>";
                }
            }
            echo "</tr>";
        }
        echo "</table>";
    }
    dzialanieNaTablicy($tab, $m);
    ?>
</div>
</body>
</html>