Php implements string flip, and php string flip. Php string flip method. php string flip this article describes how php implements string flip. Share it with you for your reference. The specific implementation method is as follows: phphead php implements string flip, php string flip
This example describes how to implement string flip in php. Share it with you for your reference. The specific implementation method is as follows:
<? Phpheader ("content-type: text/html; charset = utf-8");/** This function is used to reverse the Chinese string mb_strlen () to obtain the length of the character mb_substr () get a single element of the character krsort () sort the array implode () by key value in reverse order and concatenate the array into a string explode () using a string to separate the string */function str_rev_gb ($ str) {// Determine whether the entered character is utf8; otherwise, exit if (! Is_string ($ str) |! Mb_check_encoding ($ str, 'utf-8') {exit ("The input type is not a UTF-8 string");} $ array = array (); // Save the string to an array $ l = mb_strlen ($ str, 'utf-8'); for ($ I = 0; $ I <$ l; $ I ++) {$ array [] = mb_substr ($ str, $ I, 1, 'utf-8');} // reverse the string krsort ($ array ); // concatenate a string $ string = implode ($ array); return $ string ;}$ str1 = "Englist"; $ str2 = "English China "; $ str3 = "Eng 中llish"; $ str4 = "People's Republic of China"; echo $ str1. "-> ". str_rev_gb ($ str1 )."
"; Echo $ str2."-> ". str_rev_gb ($ str2 )."
"; Echo $ str3."-> ". str_rev_gb ($ str3 )."
"; Echo $ str4."-> ". str_rev_gb ($ str4 )."
";
I hope this article will help you with php programming.
Examples in this article describes how to implement string flip in php. Share it with you for your reference. The specific implementation method is as follows: phphead...