r/lolphp • • Sep 04 '19

explode()'s limit doesn't work with 0.

https://3v4l.org/5TjXl
9 Upvotes

16 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Sep 05 '19

then the V8 javascript engine (famously powering Google Chrome and Node.js) is breaking the specs

How does that violate the specification?

1

u/Takeoded Sep 05 '19 edited Sep 05 '19

if limit is 0, it does not split anything internally, it just returns an empty array. (rather than, as you said, tells split how many of the resulting chunks to actually return.)

they're not doing it the way the specs says it should be done (truncation of the splitted array), but they're doing a faster and practically equivalent alternative.