使用php封装文本,基于语言 [英] Wrapping a text using php, based on language

查看:94
本文介绍了使用php封装文本,基于语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我有一个很小的区域(div或span),其中显示一个到大约五个字。然而,该区域对于一些词语来说太小(例如muziekgeschiedenis将超过该区域的界限)。有没有办法在PHP包装这个词,但不仅仅是基于字符数?我可以使用wordwrap(),或者只是CSS属性为wordwrapping,但这可能会把这个词包装到muziekgeschiedeni-s,这是不想要的。它应该打入例如基于音节的muziekgeschiede-nis。是否有任何PHP扩展支持这样的打破/包装?

My problem 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?

谢谢!

推荐答案

这被称为连字符,这是google对php hyphenation的第一个链接

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

http://yellowgreen.de/phphyphenator

希望这有助于

这篇关于使用php封装文本,基于语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆