One of our pages pulls content from a database table using the following code:
<?php echo $project['description']; ?>
What I need is for all <
and >
instances to be replaced with <
and >
respectively. Can you help modify the above code to include a preg_replace
statement (or str_replace()
)?
<?php echo htmlspecialchars_decode($project['description']); ?>
Should get you what you need.
If you are ONLY looking to decode those, though, then:
<?php echo str_replace("<","<",str_replace(">",">",$project['description'])); ?>
And preg_replace should look like this:
<?php echo preg_replace(<,"<",preg_replace(>,">",$project['description'])); ?>
I'm pretty sure the &
isn't a special character, but if it does cause you issues, put a \
before it.