substr function string interception usage analysis in PHP, PHPSUBSTR
This example describes the use of SUBSTR function string interception in PHP. Share to everyone for your reference, as follows:
The SUBSTR function in PHP is defined as follows:
SUBSTR (String,start,length)
The parameters are described as follows:
string is required. A string that specifies the part to return.
Start
Necessary. Specifies where to start the string.
Positive number-starts at the specified position in the string
Negative number-starts at the specified position starting at the end of the string
0-Starts at the first character in a string
Length
Optional. Specifies the length of the string to be returned. The default is until the end of the string.
Positive number-length returned from the position where the start parameter is located
Negative number-The length returned from the end of the string
The sample code is as follows:
<?php echo substr ("Welcome to Www.jb51.net!", 0); Output as is, without capturing echo "
"; echo substr ("Welcome to www.jb51.net!", 4,14); 14 characters in a row from the 4th character echo "
"; echo substr ("Welcome to www.jb51.net!", -4,4); Intercept 4 characters from the bottom 4th.
"; echo substr ("Welcome to www.jb51.net!", 0,-4); Intercept from the first character and intercept to the 4th character?>
The results of the operation are as follows:
Welcome to Www.jb51.net!ome to Www.jb5net!Welcome to www.jb51.
I hope this article is helpful to you in PHP programming.
Articles you may be interested in:
- How the Substr_count () function Gets the number of substrings in PHP
- PHP uses the STRSTR () function to obtain a method for all characters after a specified string
- PHP strncmp () function compares the first 2 characters of a two string method
- STRNATCMP () function "Natural sorting algorithm" in PHP for string comparison usage analysis (compare strcmp function)
- strcmp () and strcasecmp () function strings in PHP comparison usage analysis
- PHP uses Trim function to remove left and right spaces and special character instances
- PHP encapsulated string encryption and decryption function
- The most accurate PHP intercept string length function
- What to do if you use substr () in PHP to intercept strings in Chinese characters.
- Summary of examples of PHP common string manipulation functions
http://www.bkjia.com/PHPjc/1089581.html www.bkjia.com true http://www.bkjia.com/PHPjc/1089581.html techarticle in PHP, substr function string interception usage analysis, PHPSUBSTR This example describes the SUBSTR function string interception usage in PHP. Share to everybody for reference, concrete as follows: PHP subs ...