I need help on writing this code, since I’m a beginner, because my teacher don’t really teach anything, nor go into full details or give examples of these type of codings, but I saw some examples of some string functions, like these:
similar_text($string1, $string2, $percent)
$real_username =“Bill Gates”;
$user_attempt = “Bill Bates”;
$check = similar_text($real_username, $user_attempt, $percent);
print($check) . “
”;
print($percent . “% correct”);
$extra_dollars = str_repeat("$", 9);
print $extra_dollars;
str_replace($look_for, $change_to, $search_text, match_count);
$search_text = “The explore function”;
$look_for = “explore”;
$change_to = “explode”;
print $search_text . “
”;
$changed_text = str_replace($look_for, $change_to, $search_text);
print $changed_text;
str_word_count(string, return ,char)
$num_of_words = str_word_count(“The word count function”);
print $num_of_words;
$string_length = strlen(“This is some text”);
substr(string, start, length)
$email = "[email protected]";
$email_end = substr($email, strlen($email) - 4);
if ($email_end = = “.com” ) {
print “ends in .com”;
}
else {
print “doesn’t end in .com”;
}
$email_address = “me” . chr(64) . “me.com”;
print $email_address;
$ascii_num = ord("@");
print $ascii_num;
$display_data = “something to display”;
print $display_data;
echo $display_data;
All of the 9 string function examples I put above are different, I don’t know how to make 10 of them with a string from user input, can someone please help? Thanks.