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...