PHP function split

Source: Internet
Author: User
Str_split () function

If an optional split_length parameter is specified, each element in the returned array is a block of characters with a length of split_length, otherwise each word converts sequential blocks to a single character.

Returns FALSE if Split_length is less than 1. If the split_length parameter exceeds the length of string strings, the entire string is returned as an array of only one element.

$str = "Hello Friend";

$arr 1 = str_split ($STR);
$arr 2 = Str_split ($STR, 3);

Print_r ($arr 1);
Print_r ($arr 2);

?>

Output

Array
(
[0] = H
[1] = = E
[2] = l
[3] = L
[4] = O
[5] = =
[6] = F
[7] = R
[8] = i
[9] = = E
[Ten] = n
[One] = d
)

Array
(
[0] = Hel
[1] = Lo
[2] = Fri
[3] = + END
)


The above introduces the PHP function split, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

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