PHP

Object-Oriented String Manipulation in PHP

Isn’t that the most boring title ever? Maybe I’ll re-title it:

You’ll never believe what this PHP class can do…

We’ll see.

Anyway, string manipulation in PHP kinda sucks. Take this example, for… example:

Granted, that code is pretty terrible. I purposely made it convoluted make a point. It takes a bit of work to figure out what’s going on, huh? Wouldn’t it be nice if we could do something like this:

Better yet, wouldn’t it be even nicer to do this:

You’d never guess this, but I made a class to do that and other things, too!

I call it, The Stringler. It does a bunch of handy stuff.

There’s also a Laravel package that gives you a helper function:

The goal with The Stringler is to approach string manipulation in an object-oriented way. This helps your code become more maintainable and easier to understand.

Feedback and contributions are welcome!

If you like bad jokes, follow me on Twitter.

4 thoughts on “Object-Oriented String Manipulation in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *