我正在将以下代码写入 .html 文件。我喜欢读出有效的值。但我只得到你在“输出”中看到的文本。我也需要在标签内打印 html 标签<td>
!
以下是浏览器打印出来的内容:
hoehere Spruenge
2x 2x 2x 2x
Adrenalin-Modus (Zeitlupe, staerkere Schlaege) (**)
2x
maximaler Sex-Appeal
2x 3x
这就是我不会得到的:
hoehere Spruenge
2x <img src="images/cheats/psx/o.gif"> 2x <img src="images/cheats/psx/d.gif"> 2x <img src="images/cheats/psx/o.gif"> <img src="images/cheats/psx/l.gif"> <img src="images/cheats/psx/r.gif"> <img src="images/cheats/psx/ve.gif"> 2x <img src="images/cheats/psx/r2.gif">
等等...
data.html 文件中的代码:
<TABLE BORDER CELLPADDING="2">
<TR>
<TD>höhere Sprünge</TD>
<TD>2x <img src="images/cheats/psx/o.gif"> 2x <img src="images/cheats/psx/d.gif"> 2x <img src="images/cheats/psx/o.gif"> <img src="images/cheats/psx/l.gif"> <img src="images/cheats/psx/r.gif"> <img src="images/cheats/psx/ve.gif"> 2x <img src="images/cheats/psx/r2.gif"></TD>
</TR>
<TR>
<TD>Adrenalin-Modus (Zeitlupe, stärkere Schläge) (**)</TD>
<TD>2x <img src="images/cheats/psx/k.gif"> <img src="images/cheats/psx/ve.gif"> <img src="images/cheats/psx/r1.gif"> <img src="images/cheats/psx/l1.gif"> <img src="images/cheats/psx/k.gif"> <img src="images/cheats/psx/u.gif"> <img src="images/cheats/psx/l.gif"> <img src="images/cheats/psx/k.gif"></TD>
</TR>
<TR>
<TD>maximaler Sex-Appeal</TD>
<TD><img src="images/cheats/psx/ks.gif"> 2x <img src="images/cheats/psx/d.gif"> <img src="images/cheats/psx/o.gif"> <img src="images/cheats/psx/ks.gif"> <img src="images/cheats/psx/r1.gif"> <img src="images/cheats/psx/l2.gif"> <img src="images/cheats/psx/o.gif"> <img src="images/cheats/psx/d.gif"> 3x <img src="images/cheats/psx/l1.gif"></TD>
</TR>
<TR>
</TABLE>
PHP代码:
<?php
// array for JSON response
$response = array();
include("functions.php");
// check for required fields
if (isset($_POST['CHEAT_VALUE'])) {
$htmltext = $_POST['CHEAT_VALUE'];
$gameid = $_POST['GAME_ID'];
$howto = $_POST['CHEAT_HOWTO'];
$plattform = $_POST['PLATTFORM_ID'];
$myFile = "data.html";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $htmltext;
fwrite($fh, $stringData);
fclose($fh);
require_once 'db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// new dom object
$dom = new DOMDocument();
//load the html
$html = $dom->loadHTMLFile("data.html");
//discard white space
$dom->preserveWhiteSpace = false;
//the table by its tag name
$tables = $dom->getElementsByTagName('table');
//get all rows from the table
$rows = $tables->item(0)->getElementsByTagName('tr');
// loop over the table rows
foreach ($rows as $row)
{
// get each column by tag name
$cols = $row->getElementsByTagName('td');
// echo the values
if($cols->item(1)->nodeValue && $cols->item(0)->nodeValue){
$datetime = date("Y-m-d");
// mysql inserting a new row
$col1 = $cols->item(0)->nodeValue;
$col2 = $cols->item(1)->nodeValue;
$col1 = ereg_replace ("ä", "ae", $col1);
$col1 = ereg_replace ("ö", "oe", $col1);
$col1 = ereg_replace ("ü", "ue", $col1);
$col1 = ereg_replace ("ß", "ss", $col1);
$col1 = ereg_replace ("Ä", "Ae", $col1);
$col1 = ereg_replace ("Ö", "Oe", $col1);
$col1 = ereg_replace ("Ü", "Ue", $col1);
$col2 = ereg_replace ("ä", "ae", $col2);
$col2 = ereg_replace ("ö", "oe", $col2);
$col2 = ereg_replace ("ü", "ue", $col2);
$col2 = ereg_replace ("ß", "ss", $col2);
$col2 = ereg_replace ("Ä", "Ae", $col2);
$col2 = ereg_replace ("Ö", "Oe", $col2);
$col2 = ereg_replace ("Ü", "Ue", $col2);
echo $col1;
echo "<br>";
echo $col2;
}else{
}
}
}
?>