可能重複:
Truncate a multibyte String to n chars
How to Truncate a string in PHP to the word closest to a certain number of characters?如何截斷整個單詞?
如:
PHP是廣泛使用的通用目的腳本語言,特別適合於Web開發,可以嵌入到HTML中。如果你是PHP的新手,並想知道它是如何工作的,
只應該顯示它的一部分。
我已經使用了substr()
函數,但結果可能是PHP is a widely-used general-purp
。輸出如何被截斷爲一個單詞,而不是一個單詞的一部分?
這是一個嚴重的問題嗎?因爲它看起來很像自動生成的垃圾郵件.. – 2011-04-11 10:31:24
和許多更多。詢問前請使用搜索功能。 – Gordon 2011-04-11 10:35:20