22.05
This commit is contained in:
15
.idea/php.xml
generated
15
.idea/php.xml
generated
@@ -10,10 +10,25 @@
|
||||
<option name="highlightLevel" value="WARNING" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpCodeSniffer">
|
||||
<phpcs_settings>
|
||||
<phpcs_by_interpreter asDefaultInterpreter="true" interpreter_id="8540242c-faae-4009-8d90-8842a998cae4" timeout="30000" />
|
||||
</phpcs_settings>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.4" />
|
||||
<component name="PhpStan">
|
||||
<PhpStan_settings>
|
||||
<phpstan_by_interpreter asDefaultInterpreter="true" interpreter_id="8540242c-faae-4009-8d90-8842a998cae4" timeout="60000" />
|
||||
</PhpStan_settings>
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="Psalm">
|
||||
<Psalm_settings>
|
||||
<psalm_fixer_by_interpreter asDefaultInterpreter="true" interpreter_id="8540242c-faae-4009-8d90-8842a998cae4" timeout="60000" />
|
||||
</Psalm_settings>
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
|
||||
@@ -24,31 +24,40 @@
|
||||
<div class="block">
|
||||
<form action="index.php" method="post">
|
||||
<label for="znaki" >Podaj 10 znaków: </label> <br>
|
||||
<input type="text" name="znaki"> <br>
|
||||
<input type="text" name="znaki" id="znaki"> <br>
|
||||
<label for="dlugosc">Podaj długość losowego słowa</label><br>
|
||||
<input type="text" name="dlugosc"><br>
|
||||
<input type="number" name="dlugosc" id="dlugosc"><br>
|
||||
<label for="ilosc">Podaj ilość słów</label><br>
|
||||
<input type="text" name="ilosc"><br>
|
||||
<input type="number" name="ilosc" id="ilosc"><br><br>
|
||||
<button type="submit">Wyświetl</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="block">
|
||||
<?php
|
||||
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$znaki = [];
|
||||
$iloscZnakow = 10;
|
||||
$iloscSlow = 0;
|
||||
$dlugoscSlowa = 0;
|
||||
$znak = '';
|
||||
if (isset($_POST['znaki'])) {
|
||||
$znak = $_POST['znaki'];
|
||||
$znaki = str_split($znak);
|
||||
if (isset($_POST['znaki']) && isset($_POST['ilosc']) && isset($_POST['dlugosc'])) {
|
||||
$znaki = str_split(trim($_POST['znaki']));
|
||||
$iloscSlow = (int)$_POST['ilosc'];
|
||||
$dlugoscSlowa = (int)$_POST['dlugosc'];
|
||||
}
|
||||
if (count($znaki) !== 10) {
|
||||
echo "<p style='color:red;'>Błąd: Podaj dokładnie 10 znaków.</p>";
|
||||
} else {
|
||||
echo "<h3>Wzorcowa tablica znaków:</h3>";
|
||||
echo "<p>" . implode(", ", $znaki) . "</p>";
|
||||
echo "<h3>Wygenerowane słowa:</h3>";
|
||||
for ($i = 0; $i < $iloscSlow; $i++) {
|
||||
$slowo = '';
|
||||
for ($j = 0; $j < $dlugoscSlowa; $j++) {
|
||||
$slowo .= $znaki[rand(0, 9)];
|
||||
}
|
||||
echo "<p>$slowo</p>";
|
||||
}
|
||||
if (isset($_POST['ilosc'])) {
|
||||
$iloscSlow = $_POST['ilosc'];
|
||||
}
|
||||
if (isset($_POST['dlugosc'])) {
|
||||
$dlugoscSlowa = $_POST['dlugosc'];
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user