我可以从 mysql 表中提取 html 而不是纯文本吗?


Can I extract html from mysql table instead of plain text?

我正在使用此代码从数据库中提取文本,它运行良好,但会去除所有 HTML 标记。

$this->data['getshorty'] = utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 640);

我宁愿能够提取包含 html 标签的字符串,然后选择在第一个或第二个段落分隔符处停止,而不是计算 640 个字符。这可行吗?

函数strip_tags()删除所有 HTML。从行中删除此功能,应该没问题。

$this->data['getshorty'] = utf8_substr(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'), 0, 640);