Php string operations

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technicians to enter strim ($ str,); remove the special characters ltrim () left rtrim () Right addslashes ($ str) on both sides of the string ); automatically transfers the string. Use stripslashes ($ str) before adding a special string to the database.

Welcome to the Linux community forum and interact with 2 million technical staff> enter strim ($ str, ""); remove the special characters ltrim () on both sides of the string left rtrim () right addslashes ($ str); automatically transfers the string and adds "\" to the special string to use stripslashes ($ str) before inserting the database;

Welcome to the Linux community forum and interact with 2 million technicians>

Strim ($ str, ""); remove special characters on both sides of the string ltrim () left rtrim () Right

Addslashes ($ str); automatically transfers strings and adds "\" to special strings before database insertion.

Stripslashes ($ str); returns the escape string of the above function.

Addcslashes ($ str, "Special Character"); escape specific characters in a string, including Chinese Characters

Stripcslashes ($ str); escape Restoration

Strlen ($ str); get the length of the string

Substr ($ str, 1,-4); truncates a string, starting from the first string to the last Fourth

Strcmp ($ str1, $ str2); compares strings by byte. If the return value is equal to 0, 1> 2, the return value is greater than 0. Otherwise, the return value is less than 0.

Strnatcmp ($ str1, $ str2); compares the numbers in a string by natural sorting. The returned values are the same as the preceding values.

Strncmp ($ str1, $ str2, len); compares the first N characters in the string

Strstr ($ str, str); search string in string $ str find the substring strchr ($ str, str) at the position where str first appears at the end of the latter; search from the back

Substr_count ($ str, str); number of times a string appears

Str_ireplace ("original string", "changed string" $ str); replace character (Case Insensitive) str_replace () case sensitive

Explode ("@", $ str); split string

Implode ("@", $ str_arr); synthesize the string separated above

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.