可能重复:
Shorten String in PHP (full words only)Substr的PHP代码 - 在单词后停止?
下面SUBSTR这IAM使用。其中回应我的数据库中的前38个字符。这个代码打破了这个词的结尾。
<?php echo substr(ucfirst($row['metadesc']),0,38); ?>...
这样的输出。
news for today was null try tomo
如何在单词结束后38个字符后停止字符串。
输出应该是这样的
news for today was null try tomorrow