string lenghth

Solutions on MaxInterview for string lenghth by the best coders in the world

showing results for - "string lenghth"
Jaime
05 May 2016
1// strip tags to avoid breaking any html
2$string = strip_tags($string);
3if (strlen($string) > 500) {
4
5    // truncate string
6    $stringCut = substr($string, 0, 500);
7    $endPoint = strrpos($stringCut, ' ');
8
9    //if the string doesn't contain any space then it will cut without word basis.
10    $string = $endPoint? substr($stringCut, 0, $endPoint) : substr($stringCut, 0);
11    $string .= '... <a href="/this/story">Read More</a>';
12}
13echo $string;
14
similar questions
queries leading to this page
string lenghth