Created
June 23, 2015 10:23
-
-
Save AlexMcowkin/057593d7301a11d498a8 to your computer and use it in GitHub Desktop.
php: обрезка заголовка по целым словам!
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 cut_title($string) | |
{ | |
$desired_width = 70; | |
$string = substr($string, 0, $desired_width+1); | |
if (strlen($string) > $desired_width) | |
{ | |
$string = wordwrap($string, $desired_width); | |
$i = strpos($string, "\n"); | |
if ($i) { | |
$string = substr($string, 0, $i); | |
} | |
} | |
return ucwords(strtolower($string)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment