开发者

why I still don't get an empty array?

开发者 https://www.devze.com 2023-01-08 03:48 出处:网络
Quoted from here: If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array

Quoted from here:

If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned.

But why I still don't get an empty array?

var_dump(explode(',', '', -1))

I get this:

array(1) {
  [0]=>
  string(0) ""
}开发者_StackOverflow中文版

UPDATE

Try it in windows,with PHP 5.2.8 (cli) (built: Dec 8 2008 19:31:23)


I can confirm that this doesn't work in PHP 5.2.8.

It does work in PHP 5.2.11. In my opinion, there are many bugs in the 5.2 branch, so try always to use the latest version. 5.3 is more stable in my experience.


I've tried this example and got empty array. Wrong question.


Tested your code, and it does return an empty array: array(0) { }.
Running PHP 5.2.11.

Maybe there's an issue with your PHP version. Can you tell us which one you are running?

0

精彩评论

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

关注公众号