Here are a couple more quick php functions for you, something you can throw in your common.php file and be used in the future if ever need be.
Click the function names which link to the code stored at Smipple.net
preg_match_count, takes a pattern, an input string, and returns the amount of times your pattern appears in the string.
preg_match_count("<[^>]*>", "<p><span>test</span></p>"); //Returns 4
starts_with, returns true or false if your input string starts with your needle.
starts_with("testing", "test"); //Returns true
starts_with("testing", "ing"); //Returns false
That’s all I got for now, hopefully I have something more to post then just small bits of simple code in the future.