Reputation: 17542
I have a string <div id="myid">
...</div>
How would I change this into
<div id="myid">
...</div>
I have tried a few things but no luck any help?
Update
function get_page(){
$file = 'file.php';
$str = file_get_contents($file);
$str = html_entity_decode($str);
return $str;
}
$output = get_page();
echo $output;//don't work
FIX
function get_page(){
$file = 'file.php';
$str = file_get_contents($file);
return $str;
}
$output = get_page();
echo html_entity_decode($output);//works
Upvotes: 4
Views: 76056
Reputation: 29
use this it's better ...
<?php
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// Allow <p> and <a>
echo strip_tags($text, '<p><a>');
?>
Upvotes: 1
Reputation: 3243
html_entity_decode
is what you need: http://www.php.net/manual/en/function.html-entity-decode.php
Upvotes: 2
Reputation: 2811
$from = array('<', '>');
$to = array('<', '>');
$string = str_replace($from, $to, $string);
Upvotes: 1
Reputation: 449843
The function for that is htmlspecialchars_decode()
.
Note that for the function to decode quotes, you need to specify the $quote_style
parameter.
Upvotes: 18