Substr functions of PHP

Source: Internet
Author: User
Substr (); substr (str, start, length); example: substr (phpisverygoodlanguage,); output as isve; when start & gt; str length, returns (); substr (phpisverygoodlanguage,); substr (phpisverygoodlan substr ();
Substr (str, start, length );
Example: substr (php is very good language, 4, 5 );
Output is ve;

If the length of start> str is returned ();
Substr (php is very good language, 26, 5 );
Substr (php is very good language, 4 );
Output as (blank)
Output is v (both start and langth are 4)

When start is a negative value, it starts to read from the end of str (* at this time, it starts to read from-1 rather than from 0 ),
Substr (php is very good language,-4, 5 );
Output as uage

When the value of length is negative, length indicates reading from the end and intercepting the end position of str.
Substr (php is very good language, 4,-5 );
Output is very good lan
Explode () splits function strings into arrays;
Strrev () returns the function string
Setlocalhost (content location) sets the local environment. content, and specifies the scenario information constants to be set include (
LC_ALL? Constants of all subordinates
LC_COLLATE? Sort order
LC_CTYPE? Character classification and conversion (for example, converting all characters into lowercase or upper case)
LC_MESSAGES? System Information format
LC_MONETARY? Currency/currency format
LC_NUMERIC? Value Format
LC_TIME? Date and time format
); Location, set the country region, for example, chs.
Strftime () format the local time/date according to the region.

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.