wamp
wamp

Reputation: 5949

why I still don't get 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) ""
}

UPDATE

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

Upvotes: 3

Views: 140

Answers (3)

Markus Hedlund
Markus Hedlund

Reputation: 24244

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.

Upvotes: 1

Macmade
Macmade

Reputation: 53950

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?

Upvotes: 0

Trurl123
Trurl123

Reputation: 132

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

Upvotes: 0

Related Questions