我正在尝试使用 excel 数据创建描述构建器。我想在 HTML 模板中使用预定义的值,并希望将 excel 值放在出现预定义值的位置,例如
<table>
<tr>
<td>ISBN</td>
<td>{ISBN}</td>
</tr>
<tr>
<td>Publisher</td>
<td>{Publisher}</td>
</tr>
<tr>
<td>Year</td>
<td>{Year}</td>
</tr>
<tr>
<td>About Book</td>
<td>{AboutBook}</td>
</tr>
</table>
HTML 模板可以从物理 HTML 文件或文本区域传递。我希望用 excel 数据替换花括号中的文本。excel 文件中的标题与 HTML 模板中的值相同,但 excel 文件每次都可以更改,其标题也可以更改,excel 文件中可能有更多标题,其中只有少数包含在 HTML 模板中。我正在使用 excelreader 从 excel 文件中获取数据
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
$xlshead[$j] = trim($data->sheets[0]['cells'][1][$j]);
}
foreach($xlshead as $hkey=>$hval) {
$row[$hkey] = trim($hval);
}
现在我得到了数组 $row 键中的列号和数组 $row 值中的标题
我在用
for ($j = 1; $j <= $data->sheets[0]['numRows']-1; $j++) {
str_replace(array_valyes($row),$data->sheets[0]['cells'][$j+1][array_$keys($row)],$_POST['strhtmltemplate'])
}
不,我不知道如何在替换功能中获得确切的密钥。请帮我。