Skip to content

Instantly share code, notes, and snippets.

View websmith's full-sized avatar

Nate Cornelius websmith

View GitHub Profile
##########################################################################
#### Script to copy install process explained in codio Wordpress Install at
### https://codio.com/s/docs/specifics/wordpress/
##########################################################################
#### Instructions
#### Option 1.
#### From the Codio Dashboard, create a new project and select the Git Tab
#### and then paste the following URL into the box
@ashrewdmint
ashrewdmint / gist:277528
Created January 14, 2010 21:33
Smart character limit functions for PHP
// Intelligently truncate a string to a certain number of characters.
// Each uppercase or wider-than-normal character reduces the final length.
function truncate($string, $length, $ellipsis = true) {
// Count all the uppercase and other wider-than-normal characters
$wide = strlen(preg_replace('/[^A-Z0-9_@#%$&]/', '', $string));
// Reduce the length accordingly
$length = round($length - $wide * 0.2);