Martha's CIS 52 Lab #1 Exercise #11

Lab #1 Exercise #11. Create a function called converter() that will take two arguments. The first argument will be upper, lower, or title. The second argument will be a string. The function should display the string in all uppercase, all lowercase, or as a title (that is, where the first letter in each word is uppercase as in, "Having Fun With Dick and Jane"). The function will be called like this:  print converter("title", $string); Click Here to see the output.  Side note:  You don't need to use forms in Lab 1 Problem 11.

**************************************************************

CODES:

  <?php	$string = "This is the string to convert. Oh My!";
function converter($conversionMethod, $string) {
global $string;
$upper = strtoupper($string);
$lower = strtolower($string);
$title = ucFirst($string);
$words = ucWords($string);
}
echo "This is the string to convert: ".$string."<br />";
echo "This is the string converted to all upper capitalization: ".converter($upper, $string)."<br />";
echo "This is the string converted to all lower capitalization: ".converter("lower", $string)."<br />";
echo "This is the string converted to a title format: ".converter("title", $string)."<br />";
echo "This is the string converted to each word capitalized: ".converter("words", $string)."<br />";
/*
function titleConverter($title, $string) {
ucwords($string);
echo $string;
}
function txt2upper($upper, $string) {
echo strtoupper($string);
}
function txt2lower($lower, $string) {
echo strtolower($string);
}
function firstWordConvert($first, $string) {
echo ucfirst($string);
}
*/
?>

**************************************************************

ANSWER:

This is the string to convert: This is the string to convert. Oh My!
This is the string converted to all upper capitalization:
This is the string converted to all lower capitalization:
This is the string converted to a title format:
This is the string converted to each word capitalized: