How to Split Strings in Different Languages... and in PHP -> TIL

12 marca 2025
ruby

I haven't been working as a programmer for super long, but my innate love for learning and discovering new things has allowed me to dabble in several programming languages, more or less commercially or as a hobby. One of the basic operations I've dealt with, even at a very basic level, is the split String operation. Recently, I've been spending a lot of time with WordPress and sometimes I need to code something in PHP, so I'd like to share with you a new discovery and how string splitting looks in the languages I've learned.

Visual Basic

More in Visual Basic docs

C#

More in C# docs

Java

More in Java docs

Swift

More in Swift docs

JavaScript

More in JavaScript docs

Dart

More in Dart docs

Python

More in Pythona docs

Ruby 💖🔥💪

More in Ruby docs

Every programming language has a split method for breaking up strings. Split is split - it works always and everywhere, but it turns out that's not entirely true...

...because now HE enters, all in white, one and only...

Crème de la crème

PHP

PHP has EXPLODE 🤣

More in PHP docs

To be fair - PHP also has a split method (check), but from what I've researched, the explode method is much more popular.

Turns out that Split String isn't such an obvious method in every language after all.