简体   繁体   中英

encoding problems with htmlespecialchars and htmlentities

Im having some trouble retrieving some info from my mysql database.

it stores that:

Comida Adultos:5<br />Comida Niños:5

and when I make that in the browser:

html_entity_decode($bookings['booking_observation'])

all is right but when I try to set to a cell with PHPExcel I get that string:

Comida Adultos:10<br />Comida Ni&ntilde;os:10

Ensure that you use UTF-8 for all the strings that you set in PHPExcel

html_entity_decode($bookings['booking_observation'], ENT_NOQUOTES, 'UTF-8')

Note that <br /> has no special meaning in MS Excel, it's simply a series of characters, so you'll probably also want to do

str_replace('<br />', "\n", $value)

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