This example describes the negative limit usage of explode in PHP. Share to everyone for your reference. The specific analysis is as follows:
Explode--use one string to split another string to make it an array.
Parameters are:
Array explode (string separator, string string [, int limit])
The final limit can not fill, at this time will be divided into the separator string all the light, if the limit filled with positive numbers, then split from left to right (limit+1) each number, if it is negative, then remove the limit array elements from the right ( The parameter is negative starting from php5.1), leaving the remaining parts to form an array.
Such as:
$str = "1 2 3 4 5 6";
Print_r (Explode ("", $str,-2));
You will see:
Array ([0] => 1 [1] => 2 [2] => 3 [3] => 4)
Visible 5, 62 elements are removed.
I hope this article will help you with your PHP program design.