====== PHP RFC: Create "split" as an alias to "explode" ====== * Version: 0.1 * Date: 2025-08-17 * Author: Vinicius Dias, carlosv775@gmail.com * Status: Draft * Implementation: https://github.com/php/php-src/pull/19490 ===== Introduction ===== PHP has the concept of [[https://www.php.net/manual/en/aliases.php|alias functions]], where a function can have more than one name. Examples of aliases are ''sizeof'', which is an alias of ''count'', ''chop'', which is an alias of ''rtrim'', ''die'', which is an alias of ''exit'', and ''join'', which is an alias of ''implode''. In several languages, the counterpart of ''join'' is ''split'', but in PHP, we call it ''explode'' (counterpart of ''implode''). This RFC proposes a new alias to the `explode` function called `split`. ===== Proposal ===== Several languages use the word ''split'' for the function that separates a string into an array using a separator and `join` for its counterpart. PHP functions for those purposes are, respectively, `explode` and `implode`. That difference from the majority of languages was mitigated with a `join` alias to the `implode` function, so a person coming to PHP from a different language has one less "strange" thing to get used to, but there is no `split` alias to `explode`. In older versions of PHP, there was a function named `split` which was part of the extension `ereg` and could be used to split a string into an array by a regular expression pattern. The `ext/ereg` was deprecated in PHP 5.3 and removed in PHP 7.0. Since then, the `split` function name has not been used and is available. This RFC has one simple purpose: creating a new function alias called ''split'' that will execute the exact same code as ''explode''. Neither parameters nor any behavior will change with this RFC. It will only make the following possible: Which would result in the following output: Array ( [0] => one [1] => two [2] => three [3] => four ) Array ( [0] => one [1] => two|three|four ) ==== Why add a new alias? ==== Some people might question how useful a new alias would be, and that is a valid concern. Whenever we developers learn a new language, we find similarities and differences from the programming languages we already know. When something is similar, we tend to assimilate it faster and feel more comfortable with the feature in question. Whenever something is very different from what we are used to, it adds some cognitive load and can make the process more challenging. As it was mentioned previously (and added to the references), multiple other programming languages use `split` as the word for this functionality, so having it in PHP would just make people coming from those languages a little bit more comfortable. [[https://news-web.php.net/php.internals/128486|As Paul Dragoonis mentioned]]: > Making it a smoother transition for JS devs to hop back on the modern PHP train is in all our shared interest in terms of user base, and split() would help this. This applies to other languages too. In the references, I am adding a small number of "complaints" in social media where users mention that `split` would be an interesting alias. ===== Backward Incompatible Changes ===== None ===== Proposed PHP Version(s) ===== 8.6 ===== Voting Choices ===== * Yes * No ===== Patches and Tests ===== https://github.com/php/php-src/pull/19490 ===== References ===== * Examples of languages that use ''split'' * [[https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/String/split|JavaScript]] * [[https://docs.python.org/3.3/library/stdtypes.html#str.split|Python]] * [[https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#split-java.lang.String-|Java]] * [[https://doc.rust-lang.org/std/primitive.str.html#method.split|Rust]] * [[https://ruby-doc.org/3.4.1/String.html#method-i-split|Ruby]] * [[https://pkg.go.dev/strings#Split|Golang]] * [[https://hexdocs.pm/elixir/1.12/String.html#split/3|Elixir]] * [[https://clojuredocs.org/clojure.string/split|Clojure]] * Social Media posts about the subject * https://x.com/ModestasMV/status/1770456102443880624 * https://x.com/misaalanshori03/status/1730592634161565954 * https://x.com/aeportugal/status/1494460629268189185 * https://x.com/RobinCalmegard/status/1484875255755821058 * https://x.com/mmartin_joo/status/1956360244222701598