PHP substr (), Explode (), Strrev () _php Tutorial

Source: Internet
Author: User
SUBSTR (str,start,length);

Example: substr (' PHP tutorial is very good language ', 4,5);

The output is the is ve;

When the length of the START>STR, it is returned as ();

substr (' PHP is very good language ', 26,5);

substr (' PHP is very good language ', 4);

Output as (blank)

Output is V (indicates start and langth are 4)

When start is negative, start reading from the end of STR (* This is read from 1 instead of starting at 0).

substr (' PHP is very good language ', -4,5);

Output is Uage

When length is a negative value, length represents the end of the read from the end and intercepts the ending position of str.

substr (' PHP is very good language ', 4,-5);

Output is very good LAN

Explode () splits the function string into arrays;

Example 1
$pizza = "Piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = Explode ("", $pizza);
echo $pieces [0]; Piece1
echo $pieces [1]; Piece2

Example 2
$data = "Foo:*:1023:1000::/home/foo:/bin/sh";
List ($user, $pass, $uid, $gid, $gecos, $home, $shell) = Explode (":", $data);
echo $gecos. "
"; Foo
Echo $shell; // *

Strrev () output string from back to forward

Echo Strrev ("June"); Outputs "Enuj"

Setlocalhost (content location) sets the local environment. Content, which 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 (for example, converting all characters to lowercase or uppercase)
lc_messages– System Information Format
lc_monetary– Currencies/Currency formats
lc_numeric– Numeric format
lc_time– Date and time formats
Location, set up a national region, for example, chs.


http://www.bkjia.com/PHPjc/445364.html www.bkjia.com true http://www.bkjia.com/PHPjc/445364.html techarticle substr (str,start,length); Example: substr (PHP tutorial is very good language,4,5); output as is ve; when startstr length, return as (); substr (PHP is ver Y good language,26,5); S ...

  • 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.