Common PHP string processing functions

Source: Internet
Author: User
$ Search: the search target value, that is, a needle array can specify multiple targets. $ Replace: the replacement value of search. An array can be used to specify multiple replications.
 
 ", $ Str); $ str = str_replace (" | _ | "," ", $ str); return trim ($ str );} /********************************** function name: msubstr ($ str, $ start, $ len) function: webpage-converted string parameter $ str: string parameter to be processed $ start: start parameter of the string to be processed $ len: length of the string to be intercepted ******************************** **/function Msubstr ($ str, $ start, $ len) {$ strlen = $ start + $ len; $ tmpstr = ''; for ($ I = $ start; $ I <$ strlen; $ I ++) {if (ord (substr ($ str, $ I, 1)> 0xa0) {$ tmpstr. = substr ($ Str, $ I, 2); $ I ++;} else {$ tmpstr. = substr ($ str, $ I, 1) ;}return $ tmpstr ;} /********************************** function name: mysql_real_escape_string function: Escape special characters in strings used in SQL statements, and take into account the connected current character set. parameter $ str: the processed string ***********************************/ function Mysql_real_escape_string ($ str) {return mysql_real_escape_string ($ str );} /************************************ function name: str_replace function: substring Replacement parameter $ search: Search target value, that is, a needle array can specify multiple targets. $ Replace: the replacement value of search. An array can be used to specify multiple replicas. Parameter $ subject: an array or string to be replaced. That is, haystack. If the subject is an array, the replacement operation will traverse the entire subject, and the return value will also be an array. Number of matching and replacement times **************************/function Str_replace ($ search, $ replace, $ subject) {return str_replace ($ search, $ replace, $ subject) ;}}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.