Home > Backend Development > PHP Tutorial > Usage analysis of negative limit of explode in PHP, explodelimit_PHP tutorial

Usage analysis of negative limit of explode in PHP, explodelimit_PHP tutorial

WBOY
Release: 2016-07-13 10:05:57
Original
794 people have browsed it

Usage analysis of negative limit in explode in php, explodelimit

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

explode -- Use one string to split another string into an array.
The parameters are:

array explode ( string separator, string string [, int limit] )
Copy after login

The last limit does not need to be filled in. At this time, the string will be divided according to the separator separator; if the limit is filled with a positive number, it will be divided into (limit+1) numbers from left to right, and if it is a negative number, it will be divided from the right Remove the limit array elements (the parameter is negative starting from php5.1), leaving the remaining parts to form an array.

For example:

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

will see:

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

It can be seen that the two elements 5 and 6 have been deleted.

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/961390.htmlTechArticleAnalysis on the usage of negative limit of explode in php, explodelimit This article describes the usage of negative limit of explode in php. Share it with everyone for your reference. The specific analysis is as follows: explode -- use...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template