This answer is going to be far less efficient than using explode()
. I would not put this in any professional script. If it is possible for your incoming string to be empty, then write a simple falsey check before exploding instead of using a preg_
call containing a literal character. If a string might have a trailing delimiter and you don't want that, then just rtrim()
the delimiter off -- again, no reason to lean on regex (and I love regex).
Comments (4)
Abullah Mahtab
10 Jan 2023This answer is going to be far less efficient than using explode(). I would not put this in any professional script.
Alchemy Admin
11 Jan 2023This is my first reply
Azharul Islam
10 Jan 2023asASAsa
Azharul Islam
10 Jan 2023asdasdasdas
Azharul Islam
11 Jan 2023aasdasdsadas
Alchemy Admin
11 Jan 2023asdada
Alchemy Admin
11 Jan 2023asdada