Monday, March 22, 2010

Removing trailing comas with PHP

November 2, 2009 by Josh Highland  
Filed under php, tutorials

Dealing with trailing comas in lists is common problem for developers. I found the best way to handle this situation in PHP is with the following regular expression.

$string = eregi_replace(’,$’, ”, $string);

Before: string = “2, 6, 9,”
After: string = “2, 6, 9″
Only the trailing coma will be stripped. If no coma is found, the string [...]

Create Wordpress Thumbnails Automatically

September 29, 2009 by Josh Highland  
Filed under php, tutorials, wordpress

WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as meta-data. This meta-data can be used by theme authors to do some pretty cool things.
The theme I am currently using allows for a custom field named “thumb”. If you create the “thumb” custom [...]