Learn Regular Expressions (regex)
Regex is a small technology that you can master in a week or two (1-2 hours/day), but it's so useful that it will pay off that investment of time on the first project you use it on. Most programming languages support them including PHP. There is a wonderful book on regex, Mastering Regular Expressions by Jeff Friedl. It starts slow, but speeds up quickly and really has everything you need to know about Regex. It's one of my favorite technical books.
Once you know Regex, you can do amazing things with awk (gawk), sed, and grep, or really with any modern programming language. Regular Expressions are not a programming language, so I suppose that's technically not an answer to your question, but Awk is a complete language and it rocks for one-off text processing.
One other thing that I feel compelled to mention is emacs. For crunching data from one format to another, I write little combinations of regular expressions and elisp right in the same buffer as the data I'm transforming. Ctrl-x Ctrl-e evaluates the previous lisp code. Ctrl-x r d deletes a currently highlighted rectangle. Between these functions, you can experiment with transforming text in a buffer until you have just what you want. It's truly interactive and wonderful. Not to mention that it's written by Richard Stallman, who also created the GNU Public License (copyleft) and started the movement most people call Open Source Software.
The Dark Side of emacs
The learning curve for emacs is very steep. It took me 6 months to be able to use emacs and 6 years to not think about it any more. Common regex characters require three back-slashes to escape them properly for emacs, which can lead to what Friedl calls, "Leaning Toothpick Syndrome."
Emacs a modeless editor, so there are lengthy key sequences for everything that can really wear out your little and ring fingers on each hand from holding down Alt, Ctrl, and Shift all day long. People jokingly call it Escape-Meta-Alt-Ctrl-Shift, but it's kind of true. Evil Mode for Emacs makes it much easier on the tendons.
Since some clown decided to add "Windows Keys" between the Alt and Ctrl keys on computer keyboards, using Emacs has become more difficult. I use an old ThinkPad keyboard from before the days of Windows Keys and have an extra in the closet in case it breaks. On newer keyboards, I like to pop off the offending keys. Hmm... That's probably too much information...
Learn Regex - it makes every language better!