Inspired by a post on dive into mark, TagifyThis is a little function I wrote a while ago, that surrounds specified strings with specified tags and attributes.
The first use I made of it was for acronyms, but it can be used for just any tag.
You give it a string, and a list of lines like
"literal" tag attribute "value", and then whenever it sees
literal in the string it converts it to
When I first blogged about it, it was broken because of a bug in PHP’s handling of PREG_SET_ORDER, and because it could only handle one list of strings and tags. It just wasn’t flexible. Now PHP is fixed, and TagifyThis handles any list of replacements that you throw at it.
More documentation in the source: tagifythis.phps.