I got the last two of my wisdom teeth pulled yesterday, and as such, I spent the day taking drugs, watching movies, and finally redoing natwelch.com.
I’ve decided to post some basic, but fun little snippets of PHP I’ve used on my personal site over the years here now that I got syntax highlighting working on my blog.
First and foremost is the age function. Given a birthdate, it returns a formated age.
Liquid error: No such file or directory - posix_spawnp
Of course this would be better if it was written so your birthday was passed in via a variable, but meh, I wrote it awhile ago.
This next piece of code is from Michael Heilemann but I’ve modified it a little, and I use it a lot, so I’ll post it here as well. It prints the time since a specified date in a kind way.
Liquid error: No such file or directory - posix_spawnp
And here is my favorite function that I wrote to parse twitter messages. It turns hashtags, urls, and replies into proper links using regex.
Liquid error: No such file or directory - posix_spawnp
Anyway, I hope these tidbits are useful. Sorry about the bad indentation, I haven’t quite gotten the hang of the wordpress plugin, Syntax Highlighter Evolved yet.
/Nat