Follow

a lot of the php stdlib naming is weird but I love explode() and implode()

· · Web · 2 · 1 · 3

wanna make an array out of this string?

BLOW IT UP

@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...

@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.

Sign in to participate in the conversation
Awoo Space

Awoo.space is a Mastodon instance where members can rely on a team of moderators to help resolve conflict, and limits federation with other instances using a specific access list to minimize abuse.

While mature content is allowed here, we strongly believe in being able to choose to engage with content on your own terms, so please make sure to put mature and potentially sensitive content behind the CW feature with enough description that people know what it's about.

Before signing up, please read our community guidelines. While it's a very broad swath of topics it covers, please do your best! We believe that as long as you're putting forth genuine effort to limit harm you might cause – even if you haven't read the document – you'll be okay!