Re: Split as an alias to explode
| From: | Vinicius Dias | Date: | Fri, 15 Aug 2025 21:18:47 +0000 |
| Subject: | Re: Split as an alias to explode | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128483@lists.php.net to get a copy of this message | ||
> We already have a function named
str_split() which does
> something else. Adding a function named split() could cause
> confusion.
I totally understand your point, but I also think that it's way more
common for people to assume str_split does what explode does and
get surprised when they see it's not the case.
I had this happening during a few conversations in PHP User Groups meetups.
I agree that having split and str_split with such different
behaviors isn't great, but I also think the benefit for newcomers to
the language to see split just like we have in several other
languages outweighs the possible confusion.
---
> I don't see value in having multiple names for the same thing, that will just cause
> confusion for folks that are used to the other name.
This is also a very valid point and I understand this line of thought.
My thought, though, is: people coming from different languages are
used to seeing split(str) or str.split(), so this would make PHP a
bit more familiar for them. Small changes like that can make a
language more "liked" for people learning them, IMO.
> As implied above and also indicated by the changed labels on the PR: RFC please.
No problem. I'll send a new e-mail to the list asking for karma (or
can this message in this thread serve as the request already)?
Thank you.