简体   繁体   中英

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

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM