Analysis on the use of negative limit of explode in php. explodelimit_PHP tutorial

Source: Internet
Author: User
Analysis of the negative limit usage of explode in php, explodelimit. Analysis of the negative limit usage of explode in php. explodelimit this article describes the negative limit usage of explode in php. Share it with you for your reference. The specific analysis is as follows: explode -- use the negative limit of explode in php, explodelimit

This example describes the usage of the negative limit of explode in php. Share it with you for your reference. The specific analysis is as follows:

Explode -- use one string to split another string and make it an array.
Parameters:

array explode ( string separator, string string [, int limit] )

The final limit can be left blank. in this case, all strings are split by the separator. if the limit field is a positive number, the number of limit + 1 is split from left to right, if it is a negative number, the limit array elements are removed from the right (the parameter is set to negative value starting with php5.1), leaving the remaining parts to form an array.

For example:

$str="1 2 3 4 5 6";print_r(explode(" " ,$str,-2));

You will see:

Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 )

The elements 5 and 6 are deleted.

I hope this article will help you with php programming.

Examples in this article describes the usage of the negative limit of explode in php. Share it with you for your reference. The specific analysis is as follows: explode -- use...

Related Article

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.