Do you ever find yourself needing to shorten a string in PHP? Maybe return the first 25 words of a long story? Give this routine a try. It will return the first n words from a string, or the entire string if it is less than n words long.
Archive for the 'Tips & Tricks' Category
I needed a way to find the first second of a week and the last second of a week based on a Unix timestamp. Credit for the previous Sunday goes to Shaun who posted a way to find it on the PHP site for strftime, although I changed his code a little because I'm more [...]
I've been using Eventum for a while to keep track of bugs in a web application of mine. There was one feature missing that I really needed, and which made me switch to dotProject for a few months and that was a timer. When I'm working on a bug I wanted a way to be [...]
Seems like Google has made it popular to change the logo of a website for holidays. My question is how many of y’all do the same, and more importantly do your members like it? Over on my photography forum I switched out the default logo with a winter themed one for Christmas. It’s scheduled to [...]
Turns out WordPress tries to make your posts look a little better by swapping out all normal quotes with smart quotes. That's great for typography, but really bad when you're posting source code like I often do on here. Trying to run pasted code with smart quotes in it will bring PHP down to its [...]