选择语言 :

 Core_Text::widont

Prevents widow words by inserting a non-breaking space between the last two words.

echo Text::widont($text);

string Core_Text::widont( string $str )

参数列表

参数 类型 描述 默认值
$str string Text to remove widows from
返回值
  • string
File: ./core/classes/text.class.php
public static function widont($str)
{
    $str = rtrim($str);
    $space = strrpos($str, ' ');

    if ( $space !== FALSE )
    {
        $str = substr($str, 0, $space) . ' ' . substr($str, $space + 1);
    }

    return $str;
}