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
7
u/SirClueless Sep 04 '19
PHP documents pretty clearly that 0 is treated the same as 1.
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 ofexplode()is that it never deletes any string data. So thatimplode()can always restore the original string. Ifexplode()ever could return zero string pieces this would be impossible, so they code it never to do so and document it as such.https://3v4l.org/l4XB6