";
// b. Convert the string to all upper case
$uppercase = strtoupper($string);
echo "Uppercase string: " . $uppercase . "
";
// c. Find the maximum and minimum length words with their corresponding length
$words = explode(" ", $string);
$maxWord = "";
$minWord = $words[0];
foreach ($words as $word) {
if (strlen($word) > strlen($maxWord)) {
$maxWord = $word;
}
if (strlen($word) < strlen($minWord)) {
$minWord = $word;
}
}
echo "Maximum length word: " . $maxWord . " (Length: " . strlen($maxWord) . ")
";
echo "Minimum length word: " . $minWord . " (Length: " . strlen($minWord) . ")
";
// d. Construct a string with hyphens between words
$hyphenString = implode("-", $words);
echo "Hyphenated string: " . $hyphenString . "
";
// e. Find the location of "PHP" in the original string
$location = strpos($string, "PHP");
echo "Location of 'PHP': " . $location . "
";
// f. Replace "PHP" with "XYZ" in the original string
$replacedString = str_replace("PHP", "XYZ", $string);
echo "Replaced string: " . $replacedString . "
";
?>