Reputation: 333
As intro.. my program read raw data from an input file.. then the program will extract, reformat and do necessary checking/filter and stored in MySQL.
The following is sample data stored in MySQL. FYI, I can't find better option than to stored the values to make it look good on display.
--------------------------------------------------------------------------------------------------------
| ID | DATA |
--------------------------------------------------------------------------------------------------------
| 1 | Carol and Anna are best friends<br>They grew up together|
| 2 | They go to same school<br>They have same hobby. |
--------------------------------------------------------------------------------------------------------
There some circumstances why i need to store the
and < br >
into MySQL. So, when i want to display it.. i just simply print it and it will appear as expected as follows:
1 Carol and Anna are best friends
They grew up together
2 They go to same school
They have same hobby
All looks good until I have data that contain special character tags such as < > or /. For example.. if i store. Carol says "That's so funny". < Carol laugh >. The words "Carol laugh" inside < > are not display on screen.
My questions are.. do we have a way to display it? or is there any option to store the data? if i use htmlspecialchars() or htmlentities(), it will display together all my and < br >
i need to store those   and < br > because there are texts that are purposely contain blanks/white spaces.
Any idea guys?
Upvotes: 0
Views: 38
Reputation: 26258
Use html_entity_decode
at the time of display the html text.
html_entity_decode — Convert all HTML entities to their applicable characters
Ex:
<?php
$orig = "I'll \"walk\" the <b>dog</b> now";
$b = html_entity_decode($orig);
echo $b; // I'll "walk" the <b>dog</b> now
Upvotes: 1