Usage analysis of negative limit of explode in php _ PHP Tutorial

Source: Internet
Author: User
Analysis of the negative limit usage of explode in php. Analysis of the negative limit usage of explode in php this article mainly introduces the usage of the negative limit of explode in php, and the usage of the limit parameter in the example analysis of explode is negative, some references can be used to analyze the negative limit usage of explode in php.

This article mainly introduces the usage of negative limit of explode in php. the usage of the limit parameter in explode for instance analysis is negative, which has some reference value. if you need it, you can refer

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:

?

1

Array explode (string separator, 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:

?

1

2

$ Str = "1 2 3 4 5 6 ";

Print_r (explode ("", $ str,-2 ));

You will see:

?

1

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.

This article mainly introduces the usage of negative limit of explode in php. the usage of the limit parameter in explode for instance analysis is negative, which has some reference value...

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.