to obtain specified characters from the string string. Relevant functions are as follows:
●substr(): Get a part of it from a string ●strstr(): Find the position where the string first appears in another string, and return the position from that position to All characters at the end of the string ●subchr(): Same as strstr() ●strrchr(): Find the last occurrence of a string in another string and return all characters from that position to the end of the string Character
substr()
Syntax:
strrchr(): The function is used to get a part of it from a string and return a string.
string substr ( string string, int start [, int length] )
Copy after login
The parameter description is as follows:
Parameter
Description
string
The string to be processed
start
Start position of the string, the starting position is 0, if it is negative, start from Starting from the specified position at the end of the string
length
Optional, the length returned by the string, the default is until the end of the string, if it is negative, it is returned from the end of the string
Tips: If start is a negative number and length is less than or equal to start, then length is 0.
strstr()
Find the first occurrence of a string in another string and return all characters from that position to the end of the string, or FALSE if not found. Syntax:
string strstr ( string string, string needle )
Copy after login
The parameter description is as follows:
Parameter
Description
string
The string to be processed
needle
To be The string to search for, if it is a number , then search for characters matching the numeric ASCII value
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn