【发布时间】:2015-02-11 02:53:51
【问题描述】:
如何使用 PHP 计算单个 HTML 行(不包括标签但包括空格)上的字符数?
在我知道单个 HTML 行(包括空格)上的最大字符数后,我需要计算链接的字符(如果有的话)和之前|之后的字符。
所以有了这些信息:
- 最大行字符。
- 如果链接:| 之前的字符之后和本身。
HTML 示例:
<p>Line one Line one Line one Line one Line one Line Line one Line one
Line two Line two Line two Line two <a href="#link">LINK</a> Line two
Line three Line three Line three Line three Line three Line three</p>
PHP:
读取第一行,计算最大字符数,如果链接,则
如果链接:计数链接字符加上之前|后。 用
创建数组"before linked text, amount of characters"
"linked text, amount of characters"
"after linked text, amount of characters"
任何帮助或见解都会很棒!谢谢你的时间。
【问题讨论】: