开发者

PHP explode without limit

开发者 https://www.devze.com 2023-02-16 10:11 出处:网络
The explode function below has a positive 开发者_开发百科limit parameter of 2. What does this parameter do, and how can I remove it?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消