Created
March 3, 2012 16:40
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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