<?php
include('includes/header.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Ashlynn's String Example</h1>
<!-- Form to accept user input -->
<form method="POST">
<label for="inputString">Enter a string:</label><br>
<input type="text" id="inputString" name="inputString" required><br><br>
<input type="submit" value="Submit">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$inputString = $_POST['inputString'];
// trim whitespace from the beginning and end of the string
$trimmedString = trim($inputString);
// convert the trimmed string to uppercase
$upperCaseString = strtoupper($trimmedString);
// convert the trimmed string to lowercase
$lowerCaseString = strtolower($trimmedString);
// replace spaces with underscores
$replacedString = str_replace(" ", "_", $trimmedString);
// get the length of the trimmed string
$lengthOfString = strlen($trimmedString);
echo "<h2>Results:</h2>";
echo "<p><strong>Original String:</strong> $inputString</p>";
echo "<p><strong>Trimmed String:</strong> $trimmedString</p>";
echo "<p><strong>Uppercase:</strong> $upperCaseString</p>";
echo "<p><strong>Lowercase:</strong> $lowerCaseString</p>";
echo "<p><strong>Spaces Replaced with Underscores:</strong> $replacedString</p>";
echo "<p><strong>Length of String:</strong> $lengthOfString characters</p>";
}
?>
<?php
echo("<br><br>");
include('includes/footer.php');
?>
</body>
</html>