如何转换<;text区域>;输出以清除html并写入文件


How to convert <textarea> output to clean html and write to file?

我的脚本编写<textarea>到文本文件:

&lt;!DOCTYPE html&gt;
&lt;html &lt;?php language_attributes(); ?&gt;&gt;
&lt;head&gt; etc

有没有我可以将输出转换为干净的html,所以它看起来像这样:

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>

etc:)

$file = 'wp.txt';
$regex = '/<textarea name="example" id="newcontent">(.*?)<'/textarea>/s';
if ( preg_match($regex, $page, $list) )
echo $list[0];
else
print "Error";
$file = 'wp.txt';
file_put_contents($file, $list, FILE_APPEND | LOCK_EX);

谢谢!

html_entity_decode

http://php.net/manual/en/function.html-entity-decode.php

这就行了。

使用方法html_entity_decode。。。。

    $file = 'wp.txt';
    $regex = '/<textarea name="example" id="newcontent">(.*?)<'/textarea>/s';
    if ( preg_match($regex, $page, $list) )
    echo html_entity_decode($list[0]);
    else
    print "Error";
    $file = 'wp.txt';
    file_put_contents($file, $list, FILE_APPEND | LOCK_EX);

您将需要html_entitiy_decode函数。