<?php
include('includes/header.php');
echo "<h2>Taylor's String Manipulation Output:</h2>";
?>
<form method="post">
<label>Enter a sentence:</label><br>
<input type="text" name="user_string" size="50"><br><br>
<input type="submit" value="Manipulate String">
</form>
<?php
if (!empty($_POST['user_string'])) {
$str = $_POST['user_string'];
echo "Original string: <b>$str</b><br><br>";
echo "Length of string: " . strlen($str) . " characters.<br>";
echo "Uppercase: " . strtoupper($str) . "<br>";
echo "Lowercase: " . strtolower($str) . "<br>";
echo "<h3>Character Breakdown:</h3>";
for ($i = 0; $i < strlen($str); $i++) {
$char = $str[$i];
echo "Position $i: Character '$char' (ASCII: " . ord($char) . ")<br>";
}
$words = explode(" ", trim($str));
echo "<h3>Array Breakdown:</h3>";
echo "Word count: " . count($words) . "<br>";
echo "<pre>";
print_r($words);
echo "</pre>";
}
include('includes/footer.php');
?>