On 15 August 2025 16:53:52 BST, Vinicius Dias <[email protected]> wrote:
>Hello, internal folks.
>
>We have `join` as an alias for `implode` so I think it makes sense to
>have `split` as an alias to `explode`, doesn't it?


There's some history here that won't be obvious to anyone who has been using 
PHP for less than a decade. 

In PHP 4 and 5 (and maybe even earlier) PHP had separate functions called 
explode() and split(). One split the string by an exact delimiter, the other 
split it by a regular expression pattern. For many use cases, these were 
interchangeable, because a pattern with no special characters in was matched 
literally; but in other cases, it caused a lot of confusion when split() gave 
unexpected results. 

The entire "Posix-Compatible Regular Expressions" extension (ext/ereg) was 
deprecated in PHP 5.3, and removed in 7.0. That included the split() function, 
leaving us with only explode().

At that point, making split() an alias of explode() would have been possible, 
but unhelpful: rather than failing with "no such function", existing code would 
have subtly changed behaviour. 

However, we have now had eight full releases with no built-in function called 
split(), so the chance of somebody upgrading in one go from PHP 5.6 to PHP 8.5 
and missing the change seems very low. If we wanted to be really conservative, 
we could plan the alias for 9.0 so there were two clear major versions between 
removal and reuse of the name.

I believe straightforward aliases like this are a single line in a stub file, 
unless there's any compiler optimisations directly referencing the name.

As such, I would broadly support adding the alias: split() is the obvious name 
for this function, and as you say it would mirror join()

Cheers,

Rowan Tommins
[IMSoP]

Reply via email to