Created
October 18, 2014 00:41
-
-
Save damiann/58d64d86345af3cb737f to your computer and use it in GitHub Desktop.
Revisions
-
damiann renamed this gist
Oct 18, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
damiann created this gist
Oct 18, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ <?php echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; function get_fname($string, $sub) { $bad = array("<", ">", ":", '"', "/", "\\", "|", "?", "*"); $name = str_replace($bad, "_", $string); echo strlen(utf8_decode($string)); if (strlen($string) > $sub) { $name = mb_substr($string,0,$sub, "utf-8"); } return $name; } $test_string = "gëén"; $sub_arr = array(1,2,3); foreach ($sub_arr as $sub) { echo get_fname($test_string, $sub); echo "<br />"; } ?>