30.05
This commit is contained in:
43
Tematy/T55/T55.3/index.php
Normal file
43
Tematy/T55/T55.3/index.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<!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>T55.3</title>
|
||||
<link rel="stylesheet" href="../style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Zadanie T55.3</h1>
|
||||
<h2>Autor: Jakub Grzegorczyk</h2>
|
||||
</header>
|
||||
<div class="box">
|
||||
<p>Dane są dwie tablice. Napisz funkcję, która otrzymuje obie tablice w argumencie i zwraca posortowaną tablicę zawierającą wszystkie elementy z pierwszej i drugiej tablicy.</p>
|
||||
</div>
|
||||
<div class="box">
|
||||
<?php
|
||||
function mergeAndSort($tab1, $tab2) {
|
||||
$result = array_merge($tab1, $tab2);
|
||||
sort($result);
|
||||
return $result;
|
||||
}
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$tab1 = htmlspecialchars($_POST['tab1']) !== null;
|
||||
$tab2 = htmlspecialchars($_POST['tab2']) !== null;
|
||||
echo "<p>Posortowana tablica: " . implode(', ', mergeAndSort($tab1, $tab2)) . "</p>";
|
||||
echo '<button><a href="index.php">Powrót do formularza</a></button>';
|
||||
} else {
|
||||
echo '<form method="post" action="">
|
||||
<label for="tab1">Tablica 1 (oddzielona przecinkami):</label><br>
|
||||
<input type="text" id="tab1" name="tab1" placeholder="1,2,3" required><br><br>
|
||||
<label for="tab2">Tablica 2 (oddzielona przecinkami):</label><br>
|
||||
<input type="text" id="tab2" name="tab2" placeholder="4,5,6" required><br><br>
|
||||
<button type="submit">Sortuj i połącz</button>
|
||||
</form>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user