src/AsyncWeb/Text/Texts.php
public static function word_substr($text, $from, $minlength, $maxlength) {
        $text = mb_substr($text, $from, $maxlength);
        $p1 = strrpos($text, ' ');
        if ($p1 >= $minlength) {
            return mb_substr($text, 0, $p1);
        }
        return $text;
    }
public static function word_substr($text, $from, $minlength, $maxlength) {
        $text = mb_substr($text, $from, $maxlength);
        $p1 = strrpos($text, ' ');
        if ($p1 >= $minlength) {
            return mb_substr($text, 0, $p1);
        }
        return $text;
    }
public static function word_substr ( $ text , $ from , $ minlength , $ maxlength ) { $ text = mb_substr ( $ text , $ from , $ maxlength ) ; $ p1 = strrpos ( $ text , ' ' ) ; if ( $ p1 >= $ minlength ) { return mb_substr ( $ text , 0 , $ p1 ) ; } return $ text ; }
This function does the substr function, but does not end the string in the middle of the word if the end is between min and max length.
This function does the substr function but does not end the string in the middle of the word if the end is between min and max length .