开发者

Wrapping a text using php, based on language

My probl开发者_StackOverflow中文版em is that I have quite a small area (div or span), in which one to about five words are displayed. However, the area is too small for some words (for instance "muziekgeschiedenis" will surpass the area's bounds). Is there a way in PHP to wrap this word, but not solely based on number of characters? I can use wordwrap(), or just CSS properties for wordwrapping, but that may wrap this word into "muziekgeschiedeni-s", which is not wanted. It should break into for instance "muziekgeschiede-nis", based on syllables. Are there any PHP extensions that support word breaking/wrapping like this?

Thanks!


this is called "hyphenation" and this is the first link that google gives on "php hyphenation"

http://yellowgreen.de/phphyphenator

hope this helps


Here is a PHP based hyphenation library, and a port of this library to a WordPress plugin: wp-Typography.


For PHP there is this PEAR Package TexHyphen, which uses the Tex algorithm to find syllables. It is alpha for six years and not maintained though, so user187291's suggestion is probably a better bet.

An alternative to PHP would be Javascript. There is a Hyphenator lib at Google Code. Keep in mind that this approach requires the user to have JavaScript enabled though. Actually, phpHyphenator is a port of this lib.


There is also this port of the TeX-Hyphenation Algorithm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜