a lot of the php stdlib naming is weird but I love explode()
and implode()
@noiob A lot of the php stdlib functions have the same history: "PHP is almost perfect, but I need a function that behaves exactly like XYZ from language ABC does for my use case. Could you add it?"
Thus, the function was copied - name and parameters included, of course, since the requester already knew that one.
@Denian most languages I've used call them split()
and join()
@noiob explode is actually an exception to the rule. It's named like that because there was already a split() function, but that one splits by RegEx, and you obviously can't use the same function to split by string delimiter that you use to split by RegEx...
@Denian lmao that sounds like php alright
@noiob If you want to have some real fun, I vaguely recall that there was a funny effect when parsing and formatting dates. There's an object oriented set of methods and a set of procedural functions, and the way I recall it, they use two different ways to specify the format... with the object oriented parser matching the procedural formatter and vice versa. You can just imagine the history behind that one.
@noiob I might be misremembering the specifics, though, since I encountered that one about 8 years ago.
@Denian hm, maybe they wanted to avoid confusion with str_split()
; join()
is an alias for implode()
at least
@noiob Possible. Also, double check your "best practices". I was always told to use "empty" instead of manually checking for null etc. - use it in a sufficiently large loop and use a profiler and you find out that empty has a lot of overhead.
wanna make an array out of this string?
BLOW IT UP