Regular expression function library: Split

Source: Internet
Author: User
Keywords PHP Chinese function manual regular expression function library
Tags aliyun array date expression function function library html http

Split

(PHP3, PHP4)

Split---&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP; To cut a string in a regular expression

Syntax: Array split (string pattern, string string [, int limit])

Description:

Returns an array of strings, using regular expression pattern as the boundary, and cutting string strings. If there is a set limit, the returned array will contain a maximum of limit elements, and the last element will contain the remaining portion of all strings. If an error occurs, split () returns FALSE.

The following examples can be obtained from the passwd line with five field data:

<?php

$passwd _list = Split (":", $passwd _line, 5);

?>

You can use a slash, a comma, or a hyphen to parse the date:

<?php

Date = "04/30/1973"; Delimiters may be slash, dot, or hyphen

List ($month, $day, $year) = Split (' [/.-] ', $date);

echo "Month: $month; Day: $day; Year: $year <br>\n ";

?>

Note: pattern is case-sensitive

Note: If you do not need formal expressive functions, you can use faster explode ()

Reference: Spliti () explode () implode ()

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.