Introduction to php string interception substr function

WBOY
Release: 2016-07-25 08:58:32
Original
1003 people have browsed it
  1. substr(php is very good language,4,5);
  2. The output is is ve;
Copy code

1, when start>str length, the return is ();

  1. substr(php is very good language,26,5);
  2. substr(php is very good language,4);
  3. The output is (blank)
  4. The output is is v (indicates that both start and langth are 4 )
Copy code

2, when start is a negative value, start reading from the end of str (*At this time, it starts reading from -1, not from 0),

  1. substr(php is very good language,-4,5);
Copy the code

The output is uage

3. When length is a negative value, length means reading from the end and intercepting the end position of str.

  1. substr(php is very good language,4,-5);
Copy the code

The output is is very good lan

In addition, explode() splits the function string into arrays; strrev() converts the function string into setlocalhost(content location) sets the local environment.content and specifies the scene information constants that need to be set ( LC_ALL – constant for all subordinates LC_COLLATE – sort order LC_CTYPE – character classification and conversion (for example: convert all characters to lowercase or uppercase) LC_MESSAGES – System message format LC_MONETARY – currency/currency format LC_NUMERIC – Numeric format LC_TIME – date and time format ); location, set the country region, for example, chs. strftime() formats local time/date according to locale settings.

That’s it for introducing these, I hope it will be helpful to everyone. To learn PHP tutorials, come to Programmer’s Home.



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