Created
October 18, 2014 00:41
-
-
Save damiann/58d64d86345af3cb737f to your computer and use it in GitHub Desktop.
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 characters
<?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 />"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment