Hey, so i have a question to do, and it asks “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);” Create a textbox so the user can put in a input (string) and radio buttons so they can choose if they want the string to be uppercase, lowercase or title.
The code i have so far is
[php]
String:
<?php $string = "This is the string to convert. Oh My!";function converter( $string, $conversionMethod) { switch($conversionMethod) { case "upper": print strtoupper($string)."
"; break; case "lower": print strtolower($string)."
"; break; case "title": print ucFirst($string)."
"; break; case "words": print ucWords($string)."
"; break; default: print $string."
"; break; } }echo "This is the string to convert:
".$string."
";echo "This is the string converted to all upper capitalization:
".converter($string, "upper")."
";echo "This is the string converted to all lower capitalization:
".converter( $string,"lower")."
";echo "This is the string converted to a title format:
".converter($string, "title")."
";echo "This is the string converted to each word capitalized:
".converter($string, "words")."
"; ?>
[/php]But the radio buttons wont say what there called, and when i input a string nothing happens. Also when i preview the page, it just says
This is the string to convert: This is the string to convert. Oh My!THIS IS THE STRING TO CONVERT. OH MY!This is the string converted to all upper capitalization: this is the string to convert. oh my!This is the string converted to all lower capitalization: This is the string to convert. Oh My!This is the string converted to a title format: This Is The String To Convert. Oh My!This is the string converted to each word capitalized:
How do i fix this? Thanks.