Php character to URL function. Code: functiontourl ($ str) {$ strpreg_replace ([^ a-zA-Z0-9] +,-, $ str); $ strtrim ($ str ,-); returnstrtolower ($ str);} contains special characters: the code is as follows:
| The code is as follows: |
|
|
Function tourl ($ str ){
$ Str = pre g_replace ('/[^ a-zA-Z0-9] +/', '-', $ str );
$ Str = trim ($ str ,'-');
Return strtolower ($ str );
} |
Contains special characters:
| The code is as follows: |
|
|
Function strtourl ($ str ){
$ Str = htmlentities ($ str, ENT_QUOTES, "UTF-8 ");
$ Str = preg_replace ('/& ([a-z] {1, 2 })(? : Acute | lig | grave | ring | tilde | uml | cedil | caron);/I ', '1', $ str );
$ Str = html_entity_decode ($ str, ENT_QUOTES, "UTF-8 ");
$ Str = preg_replace ('/[^ a-z0-9] +/I', '-', $ str );
Return strtolower ($ str );
} |
In addition to the urlencode (), urldecode (), rawurlencode (), and rawurldecode () functions provided by php in the above method, you can directly convert them using it.
The response code is as follows: function tourl ($ str) {$ str = preg_replace ('/[^ a-zA-Z0-9] +/', '-', $ str ); $ str = trim ($ str, '-'); return strtolower ($ str);} contains special characters: the code is as follows...