我在这里找到了一个示例,它显示了这样的示例:
<?php
for ($i = 1; $i <= 5; $i++) {
${a.$i} = "value";
}
echo "$a1, $a2, $a3, $a4, $a5";
//Output is value, value, value, value, value
?>
是否可以修改它以像这样工作:
for($x=1; $x<11; $x++)
{
${title.$x} = $row['${title.$x}'];
${brief.$x} = $row['${brief.$x}'];
${cost.$x} = $row['${cost.$x}'];
echo "<tr>
<td>${title.$x}</td>
</tr>
<tr>
<td>${brief.$x}</td>
</tr>
";
}
$row 数组来自 mysql 查询。