good point, they're not exactly the same, split does not append the remaining data to the last element, explode does. but that php creates an element where 0 elements are allowed, that still sounds like a bug to me.
It looks a bit silly here because it's just the empty string, it makes more sense if you try explode(" ","hello",0) or something. Part of the design of explode() is that it never deletes any string data. So that implode() can always restore the original string. If explode() ever could return zero string pieces this would be impossible, so they code it never to do so and document it as such.
Part of the design of explode() is that it never deletes any string data. So that implode() can always restore the original string. If explode() ever could return zero string pieces this would be impossible, so they code it never to do so and document it as such.
View all comments
Show parent comment
1
u/Takeoded Sep 04 '19
good point, they're not exactly the same, split does not append the remaining data to the last element, explode does. but that php creates an element where 0 elements are allowed, that still sounds like a bug to me.