PHP String Function Encyclopedia

Source: Internet
Author: User

1 Find character position function:

Strpos ($str, Search,[int]): Find the first position of search in $str starting from int;

Stripos ($str, search,[int]): function returns the position where the string first appears in another string. This function is not sensitive to case

Strrpos ($str, Search,[int]): Find the last occurrence of search in $str from int

2. Extract the character function (double byte)

Submit ($str, int start[,int length]): Extracts [length string] from strat position in $str.

Strstr ($str 1, $str 2): Searches the $str2 from the $STR1 (the first position) and intercepts it to the ending string, or false if not.

The STRISTR () feature is the same as STRSTR, but is case-insensitive.

STRRCHR () return from the last search to the word entered prompt; use: take the filename in the path

3. Replacement string

Str_replace (Search,replace, $STR): Search from $STR Replace with replace

Str_irreplace (Search,replace, $STR):

STRTR ($str, search,replace): Replace cannot be "" in this function;

Substr_replace ($Str, $rep, $start [, length]) $str The original string, $rep replaced by the new

The string, $start the starting position, $length the length of the replacement, which is optional

4, character length

int strlen ($STR)

5. Comparing character functions

int strcmp ($str 1, $str 2): $str 1>=< $str 2 is positive 1,0,-1 (string comparison)

STRCASECMP () ditto (case-insensitive)

STRNATCMP ("4", "14") compare strings by natural sort

STRNATCASECMP () ditto, (case-sensitive)

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.