确定大概的字符数。在您的示例中,它是 72 个字符。让我们找到 70 个字符后的第一个空格。
$text = '"Taking a stock of the ground realities of Indian society and the nature of the task undertaken by Maharishi Dayanand Saraswati during his life time, his followers decided to commemorate his life and works not by building lifeless statues, but by opening temples of learning - schools and colleges where all the values advocated by Maharishi would be inculcated in the children so that they could';
$last = strpos($text,' ',70);
$text = substr($text,0,$last);
echo "<p>$text</p>";
结果:
盘点印度社会和自然的基本现实
您还可以在一系列字符之间拆分多个字符:
$last = max(strpos(substr($text,0,90),' ',70),
strpos(substr($text,0,90),',',70),
strpos(substr($text,0,90),'.',70),
strpos(substr($text,0,90),';',70));