Created
January 12, 2015 00:07
-
-
Save asilbalaban/f0be33295d629cb28bb9 to your computer and use it in GitHub Desktop.
kelime bazlı substr | sub_str for words
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
function Strip_text($data,$size,$elipse = true){ | |
$data = strip_tags($data); | |
if(mb_strlen($data, 'utf-8') > $size){ | |
$result = mb_substr($data,0,mb_strpos($data,' ',$size,'utf-8'),'utf-8'); | |
if(mb_strlen($result, 'utf-8') <= 0){ | |
$result = mb_substr($data,0,$size,'utf-8'); | |
$result = mb_substr($result, 0, mb_strrpos($result, ' ','utf-8'),'utf-8');; | |
} | |
if($elipse) { | |
$result .= "..."; | |
} | |
}else{ | |
$result = $data; | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment