tags:

views:

99

answers:

3

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) ""
}

UPDATE

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

A: 

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

Trurl
Trurl, it results`array(1) { [0]=> string(0) "" }`which is non-empty
Sadat
Please use latest PHP version. May be this is a bug
Trurl
A: 

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?

Macmade
+1  A: 

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.

Znarkus