[PHP] Practical functions 5_php Tips

Source: Internet
Author: User
Tags chr ereg mixed number strings rtrim
Converts a binary representation of a number to hexadecimal

String Bin2Hex (String tring)
To drop a space at the end of a string

String RTrim (String string)
Alias of RTrim

String Chop (String string)
Remove spaces from both ends of a string

String Trim (String string)
To remove a space from the beginning of a string

String LTrim (String string)
Splits string strings with string separator and returns each component of a string string in an array

Array explode (string separator,string string)
Combining the elements and returning a string by adding glue strings between the elements of the array pieces

String implode (string Glue,array pieces)
Turn a string into a capital form

String Strtoupper (String string)
Turn a string into a lowercase form

String Strtolower (String string)
Converts the string str and the same string one by one from in from into a string in to and returns

String Strtr (String str,string from,string to)
Finds the first occurrence (case-insensitive) of a character in a string in another string

int Strpos (string haystack,string needle,int [offset])
Finds the last occurrence of a character in a string in another string, it is worth noting that needle can only be one character,
Chinese characters not suitable for

int Strrpos (String Haystack,char needle)
Converts a string into a small segment for use by other functions. For example, Base64_encode. The default is the parameter Chunklen (76 characters) per interval
76 characters are inserted into the end (""). Returns a new string without altering the original string.

String Chunck_split (String string,int[chunklen],string[end])
Extracts the length character of the string starting at the start of string strings. If start is a negative number, the tail of the string
Count up. If the parameter length that can be omitted exists but is a negative number, it means that the last length character is taken

String substr (String String,int start,int[length])
The following characters in the returned string are preceded by a backslash (\):. \+*? [^] $

String Quotemeta (String str)
Returns the ASCII (American National Code) ordinal value of the string. This function is the opposite of the CHR () function

int ord (String string)
Converts the ASCII code into a single character

string chr (int ascii)
Capitalize the first character of a string

String Ucfirst (String str)
Capitalize the first character of each word in a string

String Ucwords (String str)
Compares the same degree of two characters, returns the number of the same sequence of characters (chars) in two strings, by using the 3rd argument
Given the reference variable, pass the similar character percentage to the 3rd argument

int Similar_text (string first,string second,double[percent]
To escape single quotes, double quotes, and backslash characters in one character with a backslash

String addslashes (String str)
Remove the backslash from the string

String stripslashes (String str)
To parse a string of strings using pattern rules, the value returned by the result is placed in the array parameter regs, Regs[0]
Content is the original string string, Regs[1] is the first rule-conforming string, regs[2] is the second rule string
So If the argument regs is omitted, the return value is true only if it is simply compared.

int Ereg (string pattern,string string,array) [regs])
Similar to Ereg (), the difference is that ereg () is case-sensitive, this function is not case-insensitive

int eregi (string pattern,string String,array[regs])
This function analyzes the rules of pattern to compare string strings, and the characters to replace them are replacement parameters. return value
is a String type

String Ereg_replace (String pattern,string replacement,string string)
Constructs a case-insensitive substitution regular expression

String Eregi_replace (String pattern,string replacement,string string)
The returned value after the incision is an array variable. Parameter pattern is the specified rule string, the parameter string, and the string to be processed
, the parameter limit may omit, expresses wants to handle most conforms to the value. It is noteworthy that the pattern parameters of this function are case-sensitive

Array Split (String pattern,string String,int[limit])
This function returns the character of a string verbatim to case. This function has no effect on PHP usage, but may provide external
Department program or database processing.

String Sql_regcase (String string)
Store the data in a byte-stream manner. Variable value is a mixed type, which can include integers, double-precision floating-point number strings, and arrays to
And the object's properties (the object's method is not saved)

String serialize (mixed value)
Can take out the data that the system is stored in byte-stream way

Mixed unserialize (String str)

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.