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

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

问题描述:

I'm using this code to extract text from the database and it works well but strips all the HTML tags.

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

I would much rather be able to extract the string with html tags included and then choose to stop at the first or second paragraph break instead of counting 640 characters. Is this do-able?

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

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

我宁愿能够提取包含html标签的字符串,然后选择停在第一个或第二个段落而不是计数 640个字符。 这可以吗? p> div>

The function strip_tags() removes all the HTML. Remove this function from the line and it should be fine.

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