html_entity_decode()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

html_entity_decode()

Post by s.dot »

So, I'm trying to make an edit feature for the blogging section.

I take one of my original examples from the database which looks like this:

Code: Select all

I don\'t really write in here too much.  I suppose I use this space to write introspective, inquisitive thoughts or ideas.  And that doesn\'t really happen too often.

Perhaps I should write more <img src="smilies/biggrin.gif" alt="Smiley">.  I\'ve enhanced this blog section quite nicely.. as I have most of the site.  And I\'m still working every day to make it bigger and better.  It r0x my s0x.  So do you. =).

I\'m bouts to go fishing.. hopefully I catch something this time, and hopefully I didn\'t get sunburnt like last time.

Here\'s my sun burn from last time in case some of you haven\'t seen it yet.

<img src="http://www.showmypro.com/uploads/scrotaye/1119850355.jpg" alt="Blog Image">

Can you say <B>owww</B> ?
Perhaps I shall wear sunscreen... yes! sunscreen is the answer!

Okay, done rambling now.  TATA FUX!
The code I use to turn it into the editable version is this:

Code: Select all

$thepost = stripslashes($blog['blogentry']);

$specialtext = array("lots of values");
$replacement = array("lots of values");
$smilies = array("lots of values");
$smiliesimg = array("lots of values");

$thepost2 = str_replace($smiliesimg, $smilies, $thepost);
$thepost3 = str_replace($replacement,$specialtext,$thepost2);
$thepost4 = html_entity_decode(strip_tags($thepost3));
$thepost5 = str_replace("<br />", "", $thepost4);
Now, when I echo this, it comes out fine.

But when I try to put it into a textarea, nothing is showing up. So I viewed the source of the HTML code, and it appears as though html_entity_decode isn't working... nor is the stripslashes =/

Code: Select all

<textarea name="blogentry" id="txtPost" rows="25" cols="40" value="I don\'t really write in here too much.  I suppose I use this space to write introspective, inquisitive thoughts or ideas.  And that doesn\'t really happen too often.

Perhaps I should write more :-D.  I\'ve enhanced this blog section quite nicely.. as I have most of the site.  And I\'m still working every day to make it bigger and better.  It r0x my s0x.  So do you. =).

I\'m bouts to go fishing.. hopefully I catch something this time, and hopefully I didn\'t get sunburnt like last time.

Here\'s my sun burn from last time in case some of you haven\'t seen it yet.

[IMG]http://www.showmypro.com/uploads/scrotaye/1119850355.jpg[/IMG]

Can you say [B]owww[/B] ?
Perhaps I shall wear sunscreen... yes! sunscreen is the answer!

Okay, done rambling now.  TATA FUX!"></textarea>
Edit: I see the [ code ] [ /code] block shows my entities as quotes, but the quotes are still entities in the HTML page source.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

It's:

Code: Select all

<textarea>The value of the textarea.</textarea>
;)

By the way, what you should do is store both the bbcode and the generated html code in the database so you don't have to do that fancy shmancy reverse decoding.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

lmaoooooooooooo wow

Someone change my status from master, to newbie, right now.

Thank's alot. =)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply