Home > Backend Development > PHP Tutorial > Introduction to substr function in PHP_PHP tutorial

Introduction to substr function in PHP_PHP tutorial

WBOY
Release: 2016-07-13 17:42:11
Original
947 people have browsed it

substr();
substr(str,start,length);
Example: substr(php is very good language,4,5);
The output is is ve;

When start> ;The length of str is returned as ();
substr(php is very good language,26,5);
substr(php is very good language,4);
The output is (blank)
The output is is v (indicating that both start and langth are 4)

When start is a negative value, it starts reading from the end of str (*At this time, it starts reading from -1, not from 0 start),
substr(php is very good language,-4,5);
The output is uage

When length is a negative value, length means reading from the end, intercepting str end position.
substr(php is very good language,4,-5);
The output is is very good lan
explode() splits the function string into an array;
strrev() splits the function string
setlocalhost(content location) sets the local environment.content, and specifies the scene information constants that need to be set (
LC_ALL - constants for all subordinates
LC_COLLATE - sorting order
LC_CTYPE - character classification and conversion (such as : Convert all characters to lowercase or uppercase)
LC_MESSAGES - system information format
LC_MONETARY - currency/currency format
LC_NUMERIC - numerical format
LC_TIME - date and time format
); location, set the country region, for example, chs.
strftime() formats the local time/date according to the regional settings.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486083.htmlTechArticlesubstr(); substr(str,start,length); Example: substr(php is very good language,4 ,5); The output is is ve; When the length of startstr is, the return is (); substr(php is very good language,26,5)...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template