PHP explode without limit
The explode function below has a positive 开发者_开发百科limit parameter of 2. What does this parameter do, and how can I remove it?
$array = explode(' ', $str, 2);
In your case the array will have three elements , depending upon the value of $str , first two elements would be strings separated by space . The remaining part of the string will be the thrid element.
If $str is very long and all you need is first two elements of array then there is no point of removing 2 , latter if you like can do $array2 = explode(' ',$array[2]);
The last parameter is optional.
$array = explode(' ', $str);
Try this for splitting the $str with space (' '). No limit on items.
精彩评论