Skip to content

Instantly share code, notes, and snippets.

@mbjordan
Created March 3, 2012 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbjordan/1966913 to your computer and use it in GitHub Desktop.
Save mbjordan/1966913 to your computer and use it in GitHub Desktop.
Strip down and optimize a string for the Google Web Fonts "text" parameter.
<?php
function texterize($s = '') {
$s = str_replace(' ', '', $s);
$s = str_split($s);
$s = array_unique($s);
natcasesort($s);
return urlencode(implode($s));
}
echo texterize("This is a String with duplicate characters that needs to be stripped of white spaces and put in alphabetical order");
echo texterize("Even - non alpha-numeric chars are supported! Though that is easy!~*&^");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment