30.10
This commit is contained in:
54
Zadania/Z78 - litery/index.php
Normal file
54
Zadania/Z78 - litery/index.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
?>
|
||||
<!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>Z78 - Litery</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Zadanie Z78</h1>
|
||||
<h2>Autor: Jakub Grzegorczyk</h2>
|
||||
</header>
|
||||
<div class="box">
|
||||
<p>Napisz program, który odczytuje dwie wartości będące dużymi literami alfabetu angielskiego i wypisuje litery od pierwszej do drugiej.</p>
|
||||
</div>
|
||||
<div class="box">
|
||||
<form action="index.php" method="post">
|
||||
<fieldset>
|
||||
<label for="a">Podaj pierwszy znak (A-Z):</label>
|
||||
<input type="text" name="a" id="a" required>
|
||||
<label for="b">Podaj drugi znak (A-Z):</label>
|
||||
<input type="text" name="b" id="b" required>
|
||||
</fieldset>
|
||||
<button type="submit">Wyślij</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$a = htmlspecialchars($_POST['a']);
|
||||
$b = htmlspecialchars($_POST['b']);
|
||||
|
||||
echo '<div class="box">';
|
||||
|
||||
if (ctype_upper($a) && ctype_upper($b) && strlen($a) == 1 && strlen($b) == 1) {
|
||||
$alphabet = range('A', 'Z');
|
||||
$a1 = array_search($a, $alphabet);
|
||||
$b1 = array_search($b, $alphabet);
|
||||
echo "Pierwszy znak: $a <br> Drugi znak: $b <br> Litery: ";
|
||||
for ($i = $a1; $i <= $b1; $i++) {
|
||||
echo $alphabet[$i] . ', ';
|
||||
}
|
||||
} else {
|
||||
echo 'Litery nie są duże lub jest ich więcej niż jeden znak.';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user