PHPCookbook Reading Notes-Chapter 1 strings

Source: Internet
Author: User
The first chapter focuses on the common operations of strings. If you understand the following functions, you can skip this chapter. Strpos (): searches for the position of another string in a string. If the returned value is false, a number, or null, You need to judge substr (): specify the start position and length of a substring from a string.

The first chapter focuses on the common operations of strings. If you understand the following functions, you can skip this chapter. Strpos (): searches for the position of another string in a string. the return value is false, a number, or null. You must use ===to judge substr (): specify the start position and length of a substring from a string.

Chapter 1 focuses onStringIf you understand the following functions, skip this section.

Strpos (): InStringFind anotherStringThe return value is false, a number, or null, which must be determined by =.
Substr (): fromStringSpecify the start position and length of the childString
Substr_replace (): similar to substr (), the difference is thatStringUse anotherStringReplace

Strlen (): GetString. Here we get the length of the byte, which is not applicable to Chinese. for Chinese, we use mb_strlen ()
Strrev (): reverse the originalString
Array_reverse (): inverted Array
Str_replace (): Non-regularStringReplacement function, supports escapeString
Preg_replace_callback (): The methods starting with "preg _" are mostly regular expressions. This is the method for processing the replaced result.
Str_split (): split by lengthStringTo the array. By default, the length is one character.
Ucfirst ():StringThe first character in uppercase
Ucwords ():StringThe first word in
Strtoupper (): converts all characters to uppercase.
Strtolower (): converts all characters to lowercase letters.
Trim (): RemoveStringYou can also remove line breaks and tabs. The related functions are ltrim and rtrim.
Fputcsv (): saves data in the format of arrays as CSV data.
Fgetcsv (): similar to fputcsv, it only extracts csv data and saves it as an array variable.
Ob_start (): Enable the output buffer. All output content is displayed when the ob_get_contents () function is called.
Ob_end_clean (): clears the output cache and closes the cache. It is generally used after the ob_get_contents () function is called.
Ob_get_contents (): Get the content of the output buffer.
Pack (): Format fixed-lengthString
Unpack (): ConvertStringData is decomposed into variables.
Str_pad (): Set a length. When the number of characters in the target variable is insufficient, use anotherStringFill
Explode ():StringSplits an array by the specified separator.
Join (): combines an array into a separatorString, Alias function implode ()
Preg_split (): separated by a given regular expression.String
Wordwrap (): SetStringThe interrupt is of the specified length.String

Returned directory

Related Article

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.